The presidents of the three largest federal and postal labor unions will be prosecuted for allegedly violating the Hatch Act for political activities on behalf of Walter F. Mondale unless they resign their federal jobs or retire by Feb. 26, the government's civil service watchdog agency said yesterday.

"We have concluded that during 1983 and 1984 you engaged in campaign activity in support of the presidential candidacy of Democrat Walter Mondale and against the reelection of Republican Ronald Reagan," the Office of Special Counsel, an arm of the Merit Systems Protection Board, told the three union officials in letters released yesterday.

The Hatch Act, passed in 1939, prohibits federal workers from campaigning, raising funds, distributing literature or seeking office.

The three labor officials, Kenneth T. Blaylock of the American Federation of Government Employees, Moe Biller of the American Postal Workers Union and Vincent R. Sombrotto of the National Association of Letter Carriers, whose unions represent 1.3 million employes, have been outspoken critics of the Reagan administration.

The presidents, who have led the fight against cutbacks in federal and postal pay and benefits, said they believed that the prosecutions were politically motivated. The administration is "trying to hang us on a technicality," Blaylock said yesterday. The administration recently broadened its Hatch Act prosecutions to target union officials, he said, terming it "harassment" and "blackmail."

The three veteran union presidents can be prosecuted because of their status as federal employes on leave without pay. None has worked for a federal agency for at least 10 years. Blaylock has been on unpaid leave from Maxwell Air Force Base in Alabama since 1968, and Biller and Sombrotto on unpaid leave from the Postal Service since 1959 and 1971 respectively. Presidents of the three unions must be current or former government workers.

Federal unions make retirement fund contributions on behalf of union officials who are on leave for union business. If the three presidents quit or retire, they would no longer accumulate retirement benefits.

The cases are apparently only the second prosecutions in the 46-year history of the Hatch Act for activities carried out by union officials, according to Andrew Feinstein, staff director of the House civil service subcommittee. The first such case was in 1982, involving a local union official who wrote a newsletter article supporting a candidate.

Biller called the prosecutions "part of a continuing antilabor attack" and a misapplication of the Hatch Act, which he said was intended to protect employes from political intimidation by supervisors and was not intended to curb union officials acting in official capacities.

Sombrotto said, "I deny the charge . . . . I believe I have the right under the Constitution to speak to my membership on political candidates and issues that affect their families and their futures. We will fight this case to the Supreme Court."

Board spokesman Alma Hepner said that K. William O'Connor, the special counsel and a Reagan appointee, would have no comment on the case. But Hepner said the proposed prosecution "is not being used on a union president. The letters are not addressed to union presidents, they are addressed to federal employes . . . . Because they are union officials, they are not above the law."

Five Hatch Act cases have been prosecuted during O'Connor's tenure since October 1982. Four involved federal workers who sought elective office and a fifth involved one working on a campaign staff, according to O'Connor's 1984 annual report. The prosecutions resulted in two suspensions, one firing and one resignation, and one of the cases is pending.

Blaylock said the three unions planned to pursue the case in court because the Hatch Act in this case conflicts with other federal laws such as the Landrum-Griffin Act and the Civil Service Reform Act, which he said obligate union officials to carry out members' wishes.