H.J. Heinz Co., which sells its 57 varieties in more than 150 countries, is growing test crops of vegetables in the Soviet Union, seeking a new market for its baby food.

"We are very keen on the Soviet Union. The demand for baby food is there. It's phenomenal," said D. Edward I. Smyth, a Heinz vice president.

Along with representatives of more than 50 major U.S. food processing companies, Heinz executives gathered here yesterday at a meeting sponsored by the Food Industry's International Trade Council along with a number of Soviet government officials. Their goal was to explore how much business they could do with Moscow, but many had a common complaint: It is difficult to get profits out of the country in hard currency.

Heinz chief executive Anthony J. F. O'Reilly said that American companies have to devise creative deals with the Soviets that allow them to get profits out of the country.

He cited PepsiCo Inc.'s joint venture, in which Pepsi sells more than 9 million bottles of soft drinks a year in exchange for marketing Stolichnaya vodka in the United States.

Agriculture Secretary Clayton K. Yeutter said the size of the Soviet market is an "enticing proposition" that has drawn the interest of "very substantial U.S. companies."

Soviet President Mikhail Gorbachev told U.S. business and farm leaders in Minneapolis Sunday that "those who are with us at this time have a good prospect of cooperation in our great country."

But he warned that "those who just stand on the sidelines, who do not want to risk, who want to wait and see, who don't want to risk their dollars, well, they will remain, I think, observers for years to come. We'll make sure that that is so," according to the Associated Press.

Food production is a major problem for Gorbachev. As much as half of all food grown in the country is wasted, either when it rots in the field or spoils on the way to market.

Shelves in Moscow are so bare after a buying frenzy last week that stores are restricting sales to residents of the capital city and in retaliation, regional governments have reduced their shipments of meat, vodka and other scarce commodities to Moscow, Reuters reported.

The Central Asian Republics of Tadzhikistan and Uzbekistan, leading exporters of fresh fruits and vegetables to the rest of the Soviet Union, halted shipments beyond their borders on Friday.

Despite the payment problem, American companies are making efforts to work in the Soviet Union. Heinz, for instance, is training Soviet farmers to grow vegetables that meet its nutrition standards for baby food with yields large enough to make production economically feasible.

Conagra Inc., an Omaha-based agribusiness, last week signed an agreement to increase productivity in Soviet poultry and hog operations.

In another deal announced during the Gorbachev tour of the United States, Mayer Laboratories Inc. signed an agreement with the Ukranian Ministry of Health to make, market and distribute 225 million condoms a year, doubling the number available in the Soviet Union, Reuters reported from San Francisco.

"Because of the extreme need for condoms in the Soviet Union, this project is being given top priority by the Ukranian Ministry of Health," said David Mayer, president of privately held Mayer Labs.