The Reagan administration's top tax spokesman has endorsed congressional plans to eliminate the tax-free retirement period now enjoyed by federal, state and local government workers and by private sector employes who finance their own pension plans.

Treasury Secretary James A. Baker III said the changes -- contained in tax reform bills approved by the House and pending in the Senate -- are fair. He dismissed critics' charges that the changes would trigger a massive retirement exodus that would strip federal agencies of their best and most experienced executives, scientists and engineers.

Baker's strong endorsement of the pension tax change came in a letter to Sen. Paul S. Trible Jr. (R-Va.). Trible is one of many legislators who claim the change in pension tax rules is unfair and could cripple operations in agencies from the CIA to the IRS.

The tax reform bill would eliminate the so-called three-year recovery rule. It allows anyone who contributes to his or her own pension plan to retire and draw tax-free benefits until all contributions made to the pension fund have been recovered. For the typical civil servant -- who has already paid taxes on contributions while working -- that tax-free period lasts about 18 months.

Under the tax reform bills in Congress, persons retiring in future would have to pay taxes (prorated on their life expectancy) on their pensions. The House bill would make the change effective in July. The Senate plan would phase it in by January 1988.

Opponents claim that changing tax rules on long-time civil servants -- and others -- would upset their retirement planning and could cause hundreds of thousands of higher-paid feds (who would be hardest hit) to leave sooner than they had planned to beat the change.

Personnel officials in the National Aeronautics and Space Administraton, the FBI and other agencies have warned that many of their best people might leave early if it appears the change is going to become law. About 200,000 federal workers are eligible to retire now.

Baker's March 27 letter to Trible said that the change is necessary to eliminate "favorable treatment" given to federal workers and others who participate in contributory pension plans. Most private sector workers do not contribute to their own retirement programs, but all federal workers -- and most other public employes do.

During the period when pensions are not taxable, many federal workers take second jobs or cash in investments (such as U.S. savings bonds) so that their income will be taxed at a lower rate than if their annuities were also considered as taxable income.

Baker said the current system "distorts the behavior of this group . . . by inducing them to dispose of other taxable assets in a relatively short period immediately following retirement." That logic, while probably true, will not help the sale of saving bonds among federal workers.

The treasury secretary said that estimates of the number of feds who would retire to beat any such tax change are "overestimated." He said predictions of massive retirements in the past, when federal pension benefits were changed, never panned out.

"Second," he said in his letter to Trible, "they do not take into account the fact that earlier retirements" will trim the size of pension checks, reducing federal pension outlays in future years. "Finally," he said, "any earlier optional retirements would tend to reduce salary costs," presumably because those employes would be replaced by workers making less money, or in some cases not replaced.