Charging that the Agriculture Department "not only has egg on its face, but ketchup, too," Budget Director David A. Stockman said yesterday he had ordered the withdrawal of proposed federal rules that would have listed ketchup and pickle relish as vegetables in school lunches.

He said the controversial guidelines, which also would have allowed the substitution of soybean cakes for hamburger and doughnuts for bread, were the result of a "bureaucratic goof."

Stockman's rough-edged remarks were an obvious effort at damage-control. The proposed redefinition of the school lunch has let the Democrats embarrass the administration as rarely before. But Stockman's effort to stop one flap instantly started another. Agriculture Secretary John R. Block, whose department issued the regulation, was sorely miffed.

Block met with President Reagan late in the afternoon and later said pointedly that he and the president agreed that the guidelines should be reconsidered "due to adverse public reaction." Stockman might never have existed.

"The president and I both feel that the intent was sound and in step with the administration's goal to reduce regulation and return flexibility to the local units of government," Block said.

James Johnson, an aide to Block, later defended the regulations: "There was a great misunderstanding in the land as to how these regulations are viewed. I think it would be a mistake to say that ketchup per se was classified as a vegetable . . . . Ketchup in combination with other things was classified as a vegetable."

What other things? he was asked. "French fries or hamburgers," he replied.

A White House aide confirmed that Block was angered by Stockman's remarks. "There's some sensitivity to the way all this came out. There's also some sensitivity about what the regulations had to say in the first place."

The administration has been ridiculed since it released the regulations, which would have set the minimum lunch requirement for a kindergarten child at four ounces of milk, half a piece of bread, half a cup of fruit or a vegetable, and one ounce of meat--about one-quarter of a medium-sized hamburger.

The guidelines were supposed to help schools that provide free or reduced-price lunches to lower-income students as they try to deal with a $1 billion cut in federal support for the fiscal year that begins next Thursday.

The General Accounting Office reported earlier this month that lunches being served in many high schools already fail the basic nutritional tests and that the cutbacks could only make the situation worse.

On Thursday, a group of Democratic senators invited reporters and photographers in as they ate a school lunch consisting of a meat-and-soybean patty, a slice of bread, a few french fries, ketchup, and a partially filled glass of milk.

And yesterday, even a Republican, Sen. John Heinz of Pennsylvania, whose family owns the H.J. Heinz Co., said, "Ketchup is a condiment. This is one of the most ridiculous regulations I ever heard of, and I suppose I need not add that I know something about ketchup and relish--or did at one time."

At a White House briefing yesterday, Stockman said that on Monday he had asked James Miller, administrator of the Office of Information and Regulatory Affairs in the Office of Management and Budget, to order the Agriculture Department to withdraw the regulations because "they violated the regulatory review procedure," by not submitting the regulations to OMB for preclearance, as required by a Reagan executive order.

But faced with the Oct. 1 deadline, the department published the regulations on an emergency basis, as agencies do from time to time.

The real problem, though, appeared to be not one of the bureaucracy but of public relations. Before he even met with Block, Reagan had told a group of columnists he was going to pull back the regs.

G. William Hoagland, administrator of the Agriculture Department's Food and Nutrition Service, which oversees the school lunch program, said yesterday he had received no notice that the regulations were being withdrawn.

Hoagland said that the review of the school lunch regulations was required under the omnibus reconciliation act approved by Congress earlier this year. His department was supposed to find ways to cut school lunch costs at the local level without cutting back on the nutritional value of the meal.

He said he met with Miller earlier this week to discuss clarification of the regulations, but he said there was no discussion of eliminating the regulations.

Meanwhile, Stockman says that the Agriculture Department will be working on a new set of minimum standards for school lunches, and he reminded reporters, "Those are only minimum standards. The schools can do anything they want beyond that in terms of what kind of meals they compose."