Common Cause yesterday filed suit in federal court to block President Carter's appointment of John McGarry to the Federal Election Commission.

The action by the citizens' lobby came several hours after McGarry who was sworn in on Wednesday, assumed his seat on the commission.

McGarry is a close friend and former employe of House Speaker Thomas P. O'Neill Jr. (D-Mass.). Carter had twice before attempted to seat McGarry on the commission, in September and April of this year. But those attempts fizzled when the Senate failed to confirm the nomination.

The president appointed McGarry on an interim basis, to replace Neil O. Staebler, whose term expired in April 1977, but who had stayed on because there was no successor.

However, Staebler, 73, was contended in the lawsuit and in interviews with reporters that McGarry's latest appointment violates federal election law because it was made when the Senate was not in session.

The Common Cause suit filed in Staebler's behalf, states that "the president's naming of . . . McGarry to the Federal Election Commission without confirmation by the United States Senate is beyond the president's authority to make recess appointments . . . and therefore should be enjoined."

The suit said federal law allows Staebler to retain his seat until his successor has lawfully taken office "with the advice and consent of the Senate."

But Michael Cordozo, senior associate counsel to the president told reporters yesterday that the appointment was legal.

He said the Justice Department had ruled Tuesday that "a recess appointment to the Federal Election Commission was clearly within the power granted to the president under Article 2, Section 2, Clause 3 of the [U.S.] Constitution." A recess appointment occurs when Congress is not in session.

The constitutional clause cited by Cordozo states: "The president shall have powers to fill up all vacancies that may happen during the recess of the Senate, by granting commissions which shall expire at the end of the next session of Congress."

Cordozo argued that Carter's actions met all of the constitutional criteria, but he conceded that the matter must be decided in court.

Meanwhile, McGarry, 56, voted seven times on commission business yesterday, while Staebler met with reporters in his office.

White House and FEC officials said yesterday that Staebler's $50,000 annual salary has been discontinued. For his part, Staebler said he will remain in office; but he said he will refrain from voting on FEC matters until his case has been decided.

The FEC has taken a neutral position in the conflict.