The Reagan administration "failed badly" at the Environmental Protection Agency in its first term and should step up efforts to enforce the law and rebuild the agency's credibility, according to the Heritage Foundation.

"The administration's plan for the EPA seemed to consist of two elements: budget cuts and regulatory relief. Both backfired," the conservative think tank states in "Mandate for Leadership II," a book-length document that has been offered as a policy manual for President Reagan's second term.

In tone and content, the foundation's EPA recommendations depart sharply from those offered four years ago, which urged the administration to discard "crippling and costly" environmental regulations, pare the agency's budget and ease up on industry "through the exercise of prosecutorial discretion."

This time around, the foundation is urging expanded research, more pollution monitoring and "solid enforcement," which it called "essential to EPA's credibility."

At the same time, however, the foundation urges the administration to pursue "rational legislative changes" to reduce the "excessive costs" of pollution controls and to give the agency more freedom to balance the costs of regulations against their expected benefits.

It also urges an end to "pork-barrel programs masquerading as environmental programs," a category that it says includes federal grants for sewage-treatment plants and "Superfund" hazardous-waste cleanups.

Both are "local problems" that should be returned to the states, the group argues.

The Heritage Foundation made similar recommendations in its 1981 "Mandate for Leadership," but its latest document acknowledges that the controversy that enmeshed the agency in early 1983 has moved the goals farther away.

"At the start of the administration, the public was prepared to accept reduced environmental protection costs as long as it could feel certain that the environment still was being protected," the document states.

"By 1983, however, the credibility of the EPA had been shattered and the public had serious doubts about the administration's commitment to protecting the environment. Efforts to reduce costs were henceforth viewed with suspicion, and the prospects of enacting cost-cutting legislation shrank to zero."

Changes in environmental laws in Reagan's second term, it said, "will not be won easily, thanks in large part to the legacy of the first four years."

The chapter -- only 10 pages, compared to the 70 pages devoted to the EPA in the group's first conservative policy blueprint -- was written by Nolan E. Clark, who served briefly as the EPA's policy chief before leaving because of "irreconcilable differences" with then-Administrator Anne M. Burford. Clark is now a Federal Trade Commission official.

The Heritage Foundation's 1981 recommendations for the EPA were written by Louis J. Cordia, who later joined the agency as head of its office of federal activities. Cordia resigned in early 1983, along with Burford and more than a dozen other high-level political appointees, amid allegations of mismanagement and political manipulation of the agency's programs.

Among the foundation's specific recommendations are:

*More research, which it said "belongs at the federal level. The Reagan administration mistakenly reduced EPA's research efforts."

*Improved monitoring of pollution and stronger enforcement of law. "In its first years, the administration focused too much on negotiations," the document states. In the case of toxic-waste cleanup, it says, industry's willingness to obey the law "depends largely upon the knowledge that the alternative is litigation that will impose greater costs on the polluters than would private cleanups."