Despite overwhelming public opposition, the Agriculture Department has issued a new rule formally allowing "junk foods" -- sodas, candy and ice cream -- to be sold in schools.

Under the new regulation, junk foods are banned only from lunchrooms in schools that participate in the federal school-lunch program. The items may be sold elsewhere in the school during breakfast and lunch periods and at all other times.

John W. Bode, deputy assistant secretary for food and consumer services, said in a May 17 Federal Register notice that the new rule complies with a November 1983 U.S. Court of Appeals decision that overturned the department's ban on the sale of junk foods in schools until after the final lunch period. The court, in a case brought by the National Soft Drink Association, ruled that the department had exceeded its rule-making authority.

The new rule goes into effect June 17; however, since the court's decision, schools have been allowed, in effect, to ignore the ban on junk food sales.

During a public comment period, more than 800 persons and school officials objected to the proposed new rule, saying it would promote unnecessary competition with nonprofit school-lunch programs and could hurt the schools' efforts to provide students with nutritionally sound meals. Only 21 comments supported the rule.

Decisions about junk foods are "being left up to the local school jurisdictions," said Jean Vincent, a spokesman for the USDA's Food and Nutrition Service. "If school officials don't want junk food sold . . . , they don't have to have it."