Any public officer or employee, in any criminal action against such officer or employee arising from the officer's or employee's state employment, shall be entitled to petition the Court for a Court-appointed attorney to represent the officer's or employee's interests in the matter. If the Judge, after consideration of the petition, examination of the petitioner and receipt of such further evidence as the Judge may require, determines that the petition has merit, the Judge shall appoint an attorney to represent the interests of such public officer or employee. The Court-appointed attorney shall represent such person at all stages, trial and appellate, until the final determination of the matter, unless the attorney is earlier released by such person or by the Court. In any action where the Court-appointed attorney has been appointed in the Court of Common Pleas, such attorney shall remain the Court-appointed attorney of said public official or employee even when the case is transferred for any reason to another court of this State. This section shall also apply to all federal courts within this State.