The House voted unanimously yesterday to prohibit Soviet diplomats from occupying their new embassy in Northwest Washington until steps are taken to prevent them from conducting electronic surveillance there and security at the new U.S. Embassy in Moscow is assured.

The 414-to-0 vote reflected congressional anger over the widespread bugging of the uncompleted chancery building in Moscow and concern that the Soviet Embassy site on Mount Alto is an ideal location from which to spy on government buildings, including the White House and the Pentagon.

The bipartisan amendment was added to a bill that would authorize $8.5 billion in spending over the next two years for the State Department. The Senate Foreign Relations Committee has adopted a similar provision.

Under the House bill, the ban on Soviet occupancy of the Mount Alto embassy would be lifted if President Reagan or his successor certified to Congress that the U.S. facility in Moscow was secure and that steps were being taken to eliminate electronic surveillance from the Soviet Embassy.

The measure "in effect will hold Mount Alto hostage," said Rep. Dan Mica (D-Fla.), the chairman of the House Foreign Affairs subcommittee on international operations. "They can't use it until we use what we're going to use in Moscow."

Mica and Rep. Olympia J. Snowe of Maine, ranking Republican on the subcommittee, toured the new U.S. Embassy this spring after disclosures that a major spy operation had penetrated the old embassy.

Snowe said U.S. officials displayed a "shockingly lax attitude toward security" in overseeing construction of the chancery building in Moscow.

"The State Department arrogantly assumed that we would be able to detect and neutralize any {listening} devices in the building," she said.

The Reagan administration has appointed a panel headed by former defense secretary James R. Schlesinger to recommend what should be done with the compromised facility in Moscow.

Snowe said that Schlesinger has suggested it may be possible to reconstruct part of the building and make it secure. But she added, "I am personally skeptical of a recommendation for partial reconstruction . . . . We may have to think of starting over."

The main battle in yesterday's House debate came over an amendment by Rep. James A. Courter (R-N.J.) that would have banned any additional work on the chancery building, in effect forcing construction of a new building. Courter said the building is so compromised by Soviet intelligence devices that "we should recognize it for the KGB masterpiece it is and begin again."

Courter's amendment was defeated, 272 to 142, after Mica and Foreign Affairs Committee Chairman Dante B. Fascell (D-Fla.) argued that Congress should await Schlesinger's recommendations.

The amendment adopted by the House declares that the United States should try to recover damages from the Soviet Union for costs involved in clearing the new embassy of Soviet intelligence-gathering devices. It also directs the secretary of state to establish a program to provide "reciprocal treatment" of U.S. diplomats in the Soviet Union and Soviet diplomats here in terms of access to goods and quantity and quality of embassy real estate available to them.

The measure authorizes an additional $176 million for embassy security measures during the next two years. The security provisions call for mandatory, periodic polygraph interviews of U.S. Diplomatic Security Service personnel and, after fiscal 1989, a ban on hiring host country nationals to work in embassies and consulates in communist countries.