U.S. District Court Judge Charles R. Richey, in a victory for conservationists, ruled yesterday that federal law requires the Reagan administration to impose economic sanctions on Japan for violations of international whaling restrictions.

The decision appears to scuttle a U.S.-Japanese pact last fall that would have enabled the Japanese whaling industry to skirt a worldwide whaling ban that goes into effect next year.

A Commerce Department spokesman said the administration plans to seek an immediate stay of the decision, pending an appeal.

"Obviously, we're jubilant," said Mark Cheater, wildlife legislative director of Greenpeace, a conservation group. "We feel it's a landmark victory for whale conservationists and a clear signal that pirate whaling is not tolerated by the United States."

Alan Macnow, spokesman for the Japanese whaling industry, criticized the decision as a "rather narrowly based" legal interpretation.

"It appears that Judge Richey was rather unaware or unconcerned that the whales hunted by Japan are no longer in danger of extinction or even depletion," he said. "Richey has an established reputation as an environment-oriented judge."

The dispute touches on sensitive issues of U.S.-Japanese trade relations and Congress' role in the application of U.S. foreign policy.

Greenpeace and 11 other conservation groups sued last year to block the agreement between the Commerce Department and Japan, contending that the pact was unlawful and too lenient.

The federal law involved is the Packwood-Magnuson amendment, added to the Fishery Conservation and Management Act in 1979. It provides that violators of International Whaling Commission restrictions are subject to a 50 percent cut in rights to fish U.S. coastal waters.

Only that provision, according to conservationists, puts teeth in the IWC whale-hunting limits, since the 40-nation body has no enforcement power.

The Commerce Department argued before Richey that Commerce Secretary Malcolm Baldrige should decide whether and when to apply the sanctions by certifying a violation to the president.

Richey disagreed, saying: "It is inconceivable to this court how the secretary can reconcile his decision not to certify . . . Japanese sperm whaling with the clear purpose, intent and history of the law he is charged with enforcing."

The International Whaling Commission voted in 1982 to declare a worldwide ban on commercial whale hunting, effective next year. A ban on hunting sperm whales, effective this season, was approved as a first step.

The IWC action came amid fierce pressure from environmentalists and despite lack of agreement by its scientific staff. Japan objected to the ban that, under IWC rules, grants it an automatic exemption from the limits.

Last fall Japanese whalers began the new sperm-whale season, exempt from the international moratorium but subject to the Packwood-Magnuson sanctions.

By ordering the sanctions into effect, Macnow said, "Richey is saying the Japanese cannot exercise a right contained in the treaty."

In an effort to reach a compromise, Baldrige met last November with Hiroya Sano, director general of Japan's Fisheries Agency.

Baldrige later announced an agreement enabling the Japanese to take 400 sperm whales in the North Pacific in the 1984-85 season, 400 in the 1985-86 season, and 200 in each of the next two years without facing U.S. economic sanctions.

In exchange, according to the Commerce Department, the Japanese agreed to drop formal objections to the international ban and to comply with the worldwide ban in 1988.

Sano later denied that such an agreement had been reached, and the situation has remained muddled.