The best way, of course, is to have a functioning and fully funded public defenders office. Ideally, the public defenders office would be completely independent of any other part of judicial system in the jurisdiction. In other words, in wouldn’t be wise to make the Public Defender’s office a branch of the District Attorney’s office – this would not only raise the appearance of collusion and/or undue influence, it would almost always lead to real-life examples of same.
In jurisdictions where there isn’t enough case load, or there aren’t enough available resources to have a permanent Public Defender, there are a few other options.
In some jurisdictions, judges have the power to appoint Public Defenders from among the local criminal defense bar, on an as-needed basis. It may seem unjust to allow a judge to force an attorney to take a case, but it can be justified by pointing out that the privilege granted by the state bar to practice law also entails certain responsibilities, chief among them being to ensure no defendant goes unrepresented.
In some jurisdictions, Public Defense is provided on a sub-contract basis, with local firms bidding for the right to provide attorneys for the indigent, being paid by either a flat yearly fee, or on a per-case basis. This saves money for the jurisdiction, as they do not have to provide overhead costs to the lawyers involved.
It is also possible for local charitable and/or public interest groups to provide Public Defenders on a volunteer or low-cost basis. Most jurisdictions have some access to organizations like Legal Aid, Catholic Charities, and the like.
In very small jurisdictions, of course, these things can be handled much like it was in Harper Lee’s To Kill A Mockingbird, where the judge calls a local lawyer, asks him to take the case, and he agrees. It should always be that simple, but seldom is.