At the moment the State Department and the CIA were mapping plans to concede nothing to Moscow in the Scharansky "spy" case, the No. 2 man on the National Security Council staff leaked authoritative word that could gravely damage Anatoli Scharansky - a tragic case of ineptitude at high levels.

David Aaron, NSC Director Zbigniew Brzezinski's top deputy, leaked to Time magazine that Scharansky's onetime roommate in Moscow, Sanya Lipavsky, indded worked for the Central Intelligence Agency briefly in 1975. That leak (official denied to us by the NSC) infuriated top officials at both State and CIA. Aaron had committed a breach of ironclad espionage policy never to say one word about an undercover agent.

Without informing Brzezinski, Aaron took it upon himself to confirm Soviet claims made one year ago that Lipavsky had been in the pay of the CIA in 1975. While probably born of panic, Aaron's move seems dictated by a desire to spare the United States the unpleasant surprise of an ex-CIA agent testifying for the prosecution at Scharansky's espionage trial. But unwittingly, Aaron's leak lends superficial plausibility to the trumped-up charges against Scharansky, leader of the once flourishing anti-Soviet dissidents.

Besides potentially doleful consequences for Scharansky, this bizarre turn of events further weakens confidence in the present conduct of superpower politics in Washington. From the start, the Carter administration's management of the Scharansky affair has been bungled.

Intelligence sources here say Lipavsky was that familiar figure in Russian history, the double agent. While working for the CIA, he was also an agant of the KGB. After he blew the whistle on himself by admitting espionage for the CIA, Lipavsky would finger Scharansky as another "spy." That would deal a lethal blow to the dissident movement.

Aaron's astonishing and apparently unilateral decision to leak the truth about Lipavsky was obviously tied to the astonishing decision made by President Carter last June. He stated then that Scharansky, already under arrest, "has never had any sort of relationship to our knowledge with the CIA."

That was the first recorded case of a president publicly exonerating a foreign national from his own government's charge of spying for the United States. It gravely unsettled the CIA. By claiming Scharansky's innoncence, Carter inadvertently may have weakened him. To find him not guilty, the Russians would have to uphold the president's word against their own charge.

That may partially explain the exhaustive buildup of the Soviet case and the brutal use of Lipavsky to entrap Scharansky. Unanswered is this question: Why did Aaron tell the truth about the Lipavsky-CIA connection at this particular time and against the accepted rules of the intelligence game?

The answer, as supplied by others (Aaron did not return our telephone calls), finds its source in developments in Moscow the first week of March. As the Scharansky trial neared, American reporters learned that proof of the CIA-Lipavsky link would be part of the trial.

High officials at both State and the CIA, informed of that fact, made a conventional decision: If Lipavsky's CIA link emerges at the trial, the United States would simply lie - deny the evidence. However, if hard evidence were presented, the United States could always acknowledge the truth if needed.

But at the NSC, Aaron panicked. Those familiar with the case say he feared sudden headlines in the midst of the trial, naming Scharansky's friend Lipavsky not just a "walk-in" CIA volunteer but perhaps as a target deliberately recruited by the CIA. If the Russians came close to proving that, they could undermine the president's public statement that Lipavsky's friend Scharansky had no connection with the CIA (no matter how true.)

Under this reasoning, Aaron's decision to leak Lipavsky's CIA connection - as a "walk-in" recruit who was obviously a KGB plant - had one purpose: to protect Carter from embarrassment. But Carter never would have needed protection had he not publicly vouched for Scharansky.

Aaron's leak smacked of that very amateurism that persuaded the president to go public on Scharansky last summer, on the basis of a naive assumption that truth has power in the Kremlin.

For those still blind to Soviet reality, Moscow's real interest in the truth has been demonstrated again in the Scharansky case. The most effective pro-Scharansky witness, a young dissident named Dina Beilin, has suddenly been ordered to emigrate after six years of awaiting permission. She will not be present at the trial. Against that real-politik in Moscow, naivete in Washington is cause for concern.