While President Reagan has been alternately cozying up to the Kremlin and denouncing the Soviet Union as an evil empire intent on conquering the world, one agency of his administration has been quietly forging ahead toward closer ties with the Soviets. The unlikely engine of detente is the Housing and Urban Development Department, and it has been doing its thing with the president's explicit approval.

HUD has been swapping delegations, technology and trade shows with the Soviets under a little-noticed agreement signed in 1974 and reaffirmed by Reagan in 1984. It's called the U.S.A./U.S.S.R. Agreement on Cooperation in Housing and Other Construction.

When Reagan approved a five-year renewal of the agreement, he told HUD Secretary Samuel R. Pierce to put a capitalist spin on the deal: a chance for U.S. firms to sell their products and know-how to the Soviets.

Thanks to Pierce's able, determined assistant secretary, Dr. June Q. Koch, the commercial angle of the agreement has been pursued with marked success, involving hundreds of American businesses.

The exchange of ideas and technology began in September 1985, when Pierce and Koch visited the Soviet Union, and was followed by a high-level Soviet delegation's visit to this country in June 1986.

But the true flowering of the agreement was a trade show in Moscow last June, which included exhibits by 400 firms from 23 nations. We've seen the cable Koch sent to Washington at the close of the show.

"The U.S. pavilion at Stroyindustriya '87, with 116 American firms representing all aspects of the housing/construction sector, from high-tech to welding, is causing, in the words of the director of the larget Soviet trade organization, 'great resonance, not only in Moscow, but way beyond,' " she cabled.

Three of the U.S. companies conducting joint venture discussions with the Soviets are American Standard, Spancrete Machinery Corp. and Carlisle SynTec.

The Soviets were particularly taken with by American Standard's faucets and other plumbing hardware, long familiar to American consumers. They were fascinated by Spancrete's small, towable back-hoe, called "Dig-It," and an official from the Urals bought the exhibit model on the spot. The Carlisle SynTec product that caught the commissars' attention was a waterproof rubber roofing material that expands and contracts.

There's no predicting what will pique the Soviets' interest. A recent delegation from Moscow was enthusiastic about the plastic bathtub liner manufactured by Universal Plastics Corp.

"We put on a presentation in Washington for them," company vice president Joe Peters recalled. "My father {Jim Peters, the president} made a trip last January and Moscow officials were talking about thousands and thousands of units." Universal had a booth at the June trade fair, and the senior Peters flew over in September to close a deal with Moscow city officials.