Three years ago, when they were Nader-type lawyers working for public interest groups, Benjamin W. Heineman Jr. and Patricia Wald forced the government to transfer patients from St. Elizabeths Hospital to treatment centers near their homes.

"At the time we wondered if the $50 million, $100 million, $150 million it would cost to set up those centers was the best use of its money," recalled Heineman.

"Then we'd say, 'That's not our job. They are violating the law (by keeping patients in mental hospitals without providing proper treatment). Let's go get them.' That was the right thing to say as public interest lawyers."

Now, however, Heineman and Wald are top federal officials, among the two-dozen former public interest lawyers who have taken policy-influencing position with the Carter administration. In many cases they are now working in agencies that they were suing six months ago.

None are in Cabinet-level posts - which went to the traditional politician, corporate lawyers and businessmen - but they form a solid second and their echelon of government.

Heineman, for example, is special assistant to Health, Education and Welfare Secretary Joseph A. Califano Jr., now the defendant of record in a St. Elizabeths case that Heineman and Wald brought in mid-1974. They have both dropped out of the case.

Three other former public interest lawyers are also in the HEW hierarchy.

Patricia Wald, who ran the Mental Health Law Project in Washington, is one of four assistant attorney generals who came out of public interest legal backgrounds. She is in charge of legislation - in effect the Justice Department's lobbyist.

Others include Drew Saunders Days III, head of the Justice Department's Civil Rights Division who formerly worked for the National Association for the Advancement of Colored People's Legal Defense Fund; and James W. Moorman, head of the department's Lands and Natural Resources Division, who spent most of his career as a Sierra Club lawyer, suing the government over its land policies.

Other former public interest lawyers are working in the White House, the Office of Management and Budget, the Environmental Protection Agency and the National Oceanic and Atmosphere Administration.

This is a new breed of lawyer in government service - products of the last decade's great surge of consumerism and advocacy of public rights against what was seen as an unholy alliance of government and big business.

For the most part they worked for low salaries on advocacy cases in health, welfare and environment fields, trying to counterbalance big business through appearances at hearings, or as a last resort, lawsuits.

Their appearance in high government positions now gives lawyers still representing public interest groups increased access to top officials in the Carter administration.

Charles R. Halpern, a former attorney with the prestigious Washington firm of Arnold & Porter who now runs the coordinating and fund-raising Council for Public Interest law, said, "I'm getting the same hearing I used to get when I was with Arnold & Porter representing big corporate clients."

Top Washington law firms long have maintained that it is their ability to gain access to decision makers in government - not any influence the lawyers themselves have - that justifies their high fees.

"We are confident that the letters we send will be read," said Clarence Ditlow of the Center for Auto Safety. "The most striking difference," added Halpern, "is that you get people on the phone."

Nonetheless, public interest lawyers said they still find it hard to get their views incorporated into government policies - especially when they mean heavy spending.

"We get listened to more," said Daniel Yohalen of the Children's Defense Fund, "but we are still running into the problem of fiscal conservatism."

"I have access on a higher level now than I did in the Ford administration," added Steve Birzin of the Children's Defense Fund, "but there's little difference in policy positions."

For Heineman, the HEW official, the choices between competing priorities for scare dollars in the areas of health, education and welfare are "agonizing."

"Whereas in public interest law we saw wrong and went after it," he said, "there are so many constraints in government on what you can do."

Among them are political considerations, congressional logrolling and spending limits.

In some instances, the government has backed down on cases brought against it during the Ford and Nixon administrations by public interest groups.

The Agriculture Department, for example, quietly dropped regulations affecting food-stamp recipients and other groups of disadvantaged people, thereby allowing the Food Research Action Center to settle six suits. HEW, said Heineman, is studying all the suits against it to see if some of them can be settled, too.

These actions are probably due more to the more liberal policies of the Carter administration than to the influence of public interest lawyers in government, the lawyers said.

The public interest law movement is about eight years old, and Heineman thinks many lawyers who worked in it would have joined the government if there had been a Democratic administration.

Despite its vast influence - established through lawsuits in the fields of health, welfare, occupational safety, consumerism and the environment - there are relatively only a handful of public interest lawyers in the country.

Halpern estimated there are 600 policy-oriented public interest lawyers plus another 2,000 to 3,000 attorneys in legal service programs providing help to the poor.

The legal service attorneys have been among the most controversial - sparking suits by welfare recipients, galvanizing itinerant farmhands to demand their rights and organizing the poor to demand more services from local governments.

The Carter administration has not picked this type of lawyer for high level jobs.

"There's been a preponderance of Washington people, said Michael Trister, a lawyer with a public interest practice." It (the administration) failed to look at legal service attorneys in the areas of housing, welfare and consumer problems that affect the poor."

For the lawyers leaving public interest groups, where many earned under $12,000 a year and worked in cramped, messy offices, moving to the government had been a bonanza. Most are earning close to $50,000 and their government offices appear palatial compared to their former quarters.

Ralph Nader, the George Washington of public interest groups, has suggested that these lawyers contribute 10 per cent of their government salaries to public interest groups.

There is a fear among some public interest groups that their former colleges will get used to the high salaries and posh working conditions of government service and never return to public interest law.

Traditionally, when lawyers leave the government they go into private industry they are most familiar with - the field in which they worked in the federal service.

"The real question," said Halpern, "is what the public interest lawyers will do when they leave government service."