Two former Soviet employes of the United Nations were sentenced to 50 years in prison each yesterday for their roles in an elaborate espionage scheme aimed at buying U.S. military secrets.

At the government's request, the two spies were freed pending their appeals as a conciliatory gesture to the Soviet Union. Judge Frederick B. Lacey, sitting in U.S. District Court in Newark, acceded to the government's wishes that "for foreign policy considerations" Valdik Enger and Rudolf Chernyayev be confined to the area surrounding their Soviet residence in the Bronx in the custody of the Soviet ambassador.

Some U.S. foreign policy officials expressed surprise at the severity of the sentence. But they said they expected the Soviet government would be satisfied with the freedom granted the spies and would not take any retaliatory steps.

They also said that any talk of trading Enger and Chernyayev for dissidents held in Soviet prisons was "speculative." Such a trade was not now being seriously discussed, they said.

One noted, however, that Enger and Chernyayev are "the only ones we've got" if an exchange were contemplated.

The arrest last May of Enger and Chernyayev and the decision to put them on trial helped set off a spiral of retaliatory acts on both sides and contributed to a summer of unusual strain in U.S.-Soviet relations.

The Russians regarded the case as a serious breach of an international etiquette that called for handling such spy cases quietly, without formal and highly publicized trials.

The Soviets retaliated by dragging an American businessman, Francis J. Crawford, from his car on a Moscow street and charging him with currency violations. He has since been convictred and freed in a Soviet gesture of conciliation.

Enges and Chernyayev were set up by Lt. Cmdr. Arthur F. Lindberg, who testified that he accepted an undercover assignment from the FBI to help them track down a Soviet spy network which used the Soviet merchant marine as cover.

Lindberg testified that he made his first contact on a cruise aboard a Russian passenger ship by leaving a not saying he would exchange documents for money.

Later, a man with a heavy accent contacted him by phone and said the Russians "were pleased to receive your note."

The naval officer, under constant observation by the FBI, then began providing bogus defense information in a series of drops along crowded highways in the New York area. The Russians funneled cash to him in $2,000, $3,000 and $5,000 chunks, concealed in orange juice containers and radiator hoses. They also gave him a $1,000 "Christmas bonus," according to testimony, and instructions not to flaunt his wealth.

Enger, Chernyayev and a third Russian, Soviet U.N. Attache Vladimer P. Zinyakin, were taken into custody on May 20 at a Woodbridge, N.J., shopping center where they went to fetch a roll of film dropped by the counter-spy. Zinyakin, who had diplomatic immunity was later relased.

The others were indicted on charges that they paid the naval officer more than $20,000 for defense doucments, including antisubmarine warfare materials, over a nine-month period.

Judge Lacey, who could have sentenced the Soviet to life imprisonment, said he imposed the 50 year terms to prevent the Soviet Union from doing "what one of their leaders once said he would do - bury us."

Lacey also criticized the United Nations, which had hired the two men, for not screening potential employes. "I ask myself how many FBI agents have to be assigned to representatives of the Iron Curtain countires to make sure our hospitality is not undermined," Lacey said.