A politically connected employee who held a comfortable $140,000-a-year job in the city Comptroller’s ­Office was forced out after getting caught doing personal work on city time — for 14 years.

Carmen Martinez, who served as director of the comptroller’s Community Action Center, admitted that she used “an excessive amount” of city time and resources to work on behalf of various nonprofits since 2000, according to Conflicts of Interest Board documents.

Her most recent rule violations include contacting four city agencies — the NYPD and Parks Department among them — on behalf of a block association she heads in Prospect-Lefferts Gardens, Brooklyn.

Martinez agreed to retire after the office brought charges against her in March, including for ­unspecified misconduct.

Martinez, once a campaign treasurer for then-Brooklyn Democratic leader Clarence Norman Jr., was granted immunity for testifying against him before a grand jury. He was convicted in 2005 of accepting illegal contributions.

Attempts to reach Martinez were unsuccessful, and Comptroller Scott Stringer declined to comment.