The District government and unions representing 13,000 city employes reached tentative agreement yesterday on a new three-year contract that includes a one-time bonus of at least $500 per worker the first year and salary increases totaling 7.5 percent during the second and third years.

Mayor Marion Barry intervened in the talks late this week, according to city officials, after the lengthy negotiations had reached a stalemate and union officials had threatened to take unspecified job actions in retaliation for efforts by the city to pressure the workers.

The contract, which would cost the city an additional $40 million if approved by union members and the City Council, provides a 1.5 percent pay adjustment in the final month of the contract as a sweetener.

The District also would continue to pay the full cost of employes' dental and optical costs under the agreement, after city negotiators backed down from efforts to do away with those benefits.

Last week, as the old contract was about to expire, labor leaders angrily accused city officials of cutting off dental and optical insurance premiums to pressure the unions to accept what they considered a paltry contract offer.

The tentative settlement covers the white-collar and blue-collar work force, including sanitation workers, correctional officers, emergency medical personnel and others. The city has yet to reach agreement with representatives of another 7,000 employes, including police officers and firefighters.

"This three-year agreement provides equity for both sides," City Administrator Thomas Downs said yesterday in announcing the tentative agreement. " . . . As a result of the settlement, the mayor indicated that he would not be required to institute RIFs reductions in force over the term of the contract."

Union officials yesterday hailed the agreement as one that is fair to both sides and retains many benefits important to workers, including the current sick leave and annual leave policies.

"A lot of our membership are women that are heads of households," said Ron King, chief negotiator for the American Federation of Government Employees. "Job security and dental and optical and benefits such as those to people who have to put the groceries on the table -- those are very critical issues for them."

Joseph McQuillen, an official with the National Association of Government Employees and the International Brotherhood of Police Officers, said, "It's something we can sell and live with."

The agreement would also apply to members of the American Federation of State, County and Municipal Employees, the Communications Workers of America and the Laborers Union.

Agreements in the past have come long before the deadlines, and the last contract, negotiated in the election year of 1982, included raises of roughly 21 percent over three years and inclusion of the dental and optical benefits.

But the city was much tougher at the bargaining table this year, according to union officials, who contended that Barry took a harder line because he did not need union support from which he benefited in the last campaign. Barry's term is not up until 1986.

This year, the District proposed to freeze pay scales for two years, to provide a one-time bonus in the second year and to give a raise of less than 3 percent in the third year.

Under the agreement announced yesterday, city workers would get a one-time bonus in the first year of 3 percent of their salary or $500, whichever is larger. The average bonus would be about $625, according to Donald H. Weinberg, the city's chief of labor relations.

Workers then would receive a 3.5 percent pay increase over their current base in the second year and an additional 4 percent increase in the third year. The additional 1.5 percent increase at the tail end of the contract would boost the workers' pay base going into the next round of contract talks.