SPRINGFIELD, Ill.—It pays for veteran firefighters and police officers here to retire around the anniversary of their hiring date—but it's costly for this city of 117,000.

Under current labor agreements, employees get a 5% bump in the pay periods around that date every year. Workers who retire during the short window get a perk: Their pensions are based on the temporarily boosted paycheck. The provision, which starts after two decades...