In a slap at President Reagan, the House yesterday approved by a 3-to-1 ratio a nonbinding resolution condemning the administration's vote against an ethical code for marketing baby formula in Third World countries.

The joint resolution, which passed 301 to 100 after 40 minutes of emotional debate, urges the administration nonetheless to cooperate with other nations in implementing the World Health Organization code and urges the formula industry to abide by the code's voluntary guidelines.

The Reagan administration reversed prior U.S. government policy, making the United States the only country out of 119 to oppose the code when the WHO adopted it in Geneva May 21. The code, developed in cooperation with formula manufacturers, provides standards to combat overly aggressive marketing of baby formula that has allegedly persuaded millions of Third World women to abandon breastfeeding.

The resolution cited studies contending that the use of formula, mixed with polluted water, placed in dirty bottles and contaminated by flies and tropical heat, accounts for up to a million infant deaths a year in underdeveloped countries.

The resolution, which also requires Senate approval, comes on the heels of the withdrawal of Ernest W. Lefever as the Administration's nominee for assistant secretary of state for human rights. Lefever was criticized for accepting funds from Nestle Corp., and leading formula maker, while attacking the formula code through his nonprofit policy center.

The administration yesterday called the House resolution "ill timed and inappropriate," questioning the right of the WHO to impose restrictions on private companies and contending that the code limits freedom of speech.

Proponents, however, emphasized the resolution's voluntary nature, and as many Republicans as Democrats spoke in its favor. "Nothing could be more unfortunate than for our country to have come out against 'motherhood' in Third World countries and for what many perceive -- rightly or wrongly -- to be nothing less than child killing: all for the sake we are told, of Madison Avenue free speech and greater corporate profits," said Rep. Jim Leach (R-Iowa).

The code is designed to limit the promotion of formula by women dressed in nursing uniforms, the use of ads disguised as educational materials, company payoffs to health professionals and promotional posters in health clinics equating progress with formula feeding.

Breastfeeding, the resolution states, "has substantial advantages for infant health . . . offers an uncontaminated food supply, an early transfer of antibodies protective against infectious diseases, and a naturally evolved and tested nutritional source . . . it is an important factor in bonding between mother and child."

The entire Maryland delegation voted for the resolution, except for Beverly B. Byron, who was not present. In the Virginia delegation, the lone Democrat, Dan Daniel, opposed it. Among Virginia Republicans, Thomas J. Bliley Jr., William C. Wampler, G. William Whitehurst and Frank R. Wolf voted for it, and M. Caldwell Butler, Robert W. Daniel Jr., J. Kenneth Robinson and Paul S. Trible Jr. opposed it. Stan Parris did not vote.

Meanwhile, before two subcommittees of the House, representatives of the formula industry and the Reagan administration defended their decision.

"This code has the potential to harm infant health and increase mortality, not decrease it," said David Cox, chairman of Ross Laboratories, a maker of infant formula marketed abroad.

He said that mothers who give up breastfeeding or who must supplement breastfeeding with other foods often get poor information about what is needed to keep children from becoming malnourished.

Cow's urine, corn meal, yams, melons and other foods without enough nutritional value to prevent malnourishment are among the foods given to Third World babies, he said. He and other leader of formula-making companies said they would abide by the code but expressed skepticism that many countries would adopt it whole.

The formula makers said there was no data that indicated that their marketing practices have encouraged women to switch from breastfeeding to formula.

If there is a decline in breastfeeding in the Third World it could hardly come from the influx of formula, Cox said. "When one realizes that all the infant formula sold by all companies in Third World environments would barely provide 6 percent of all the calories fed to infants in the first year of life . . . one must search elsewhere for a cause."

More loud and fiery was former senator Sam Ervinof North Carolina who appeared for the Grocery Manufacturers of America. "This code operates on the totalitrian theory that only the government is in possession of all the facts," he said. "It is a complete denial of the right to information for mothers and their babies. . . ."