President Carter stepped up the public pressure on U.S. allies yesterday, expressing disappointment about the response of some countries to the Iranian crisis and warning that the benefits of detente may be lost by failure to deter Soviet aggression.

In a broad defense of his conduct of foreign policy, Carter told the American Society of Newspaper Editors convention that he does not regret the restraint the United States has shown in reacting to the holding of American hostages by Iranian militants in Tehran.

But the president reiterated that the United States reserves the right to use military force to resolve the crisis and in response to a question, said that "we've been disappointed" by the unwillingness of some allies to pressure Iran by economic and diplomatic means.

Carter returned to the same theme in discussing the Soviet Union's invasion of Afghanistan. Bluntly warning that he will take whatever "legal actions" are necesaary to prevent American athletes from participating in the Moscow Olympics, a step many U.S. allies appear reluctant to support, the president said, "The American people have demonstrated that they are willing to bear their share of the burden.

"But it is also vital that the burden of sacrifice also be shared among our allies and other nations.

"Neither we nor our allies want to destroy the framework of East-West relations that has yielded concrete benefits for so many people. But, ultimately, if we continue to seek the benefit of detente while ignoring the necessity for deterrence, we would lose the advantages of both."

Carter's comments were as close as he has come to outright criticism of the allies and came against a backdrop of a concerted administration effort to persuade Japan and Western European nations to exert more pressure on Iran to free the 53 hostages.

The president said that he has suggested to allied leaders that they impose their own economic sanctions or sever diplomatic relations with Iran -- steps that the United States took unilaterally on Monday. Carter, however, did not indicate whether he expects the allies to go along.

Washington Post Correspondent Leonard Downie Jr. reported from London yesterday that the United States is discussing with its allies how much their economies would suffer if they stopped buying Iranian oil or had it cut off in retaliation for imposing economic sanctions against Iran.

According to informed sources, these discussions, which took place Wednesday between Secretary of State Cyrus R. Vance and about two dozen allied ambassadors in Washington, did not include a specific American request for a halt in allied purchases of Iranian oil.

Europe is much more dependent than is the United States on oil imports from Iran, and European diplomats continued to express concern that much harsher economic and diplomatic sanctions could backfire by completely cutting off Iran from the western powers.

According to senior administration officials, the American counter argument to the allies has been that their oil-dependent economies will be better off if they impose sanctions on Iran now than if the United States is forced to take the next likely unilateral step to resolve the crisis -- a naval blockade of Iran.

According to this argument, even if Iran retaliates against the allies by shutting off direct oil sales, some Iranian oil will make its way to Europe and Japan through the international market. But if the United States blockades Iran, no oil will get out.

There wad evidence yesterday that the growing public and private American pressure on the allies was having some effect.

State Department officials said that West Germany was withdrawing its ambassador from Tehran and that Japan was exploring restraints on trade and development loans to Iran. Norway also announced that it was withdrawing its ambassador from Tehran for consultation in response to Carter's appeal.

In his speech to the editors, the president did not single out any allied nation for criticism. But he portrayed the United States as coming under often conflicting pressures from nations that "ask America for a response to myriad -- and often conflicting -- concerns."

"Nations ask us for leadership, but at the same time they demand their independence of action," he said. "They ask for aid, but they reject any interference. They ask for understanding, yet often decline to understand us in return.

"Some ask for protection, but are wary of the obligations of alliance. Others ask for firmness and certainty, but at the same time demand the flexibility required by the pace of change and the subtlety of events."

The speech contained some of Carter's strongest rhetoric on Iran and Afghanistan.

"Every day that the crisis continues, Iran is further isolated," he said. "Every day that the American Embassy remains a prison pushes Iran itself further into lawlessness, down and down the spiral of disorder."

On Afghanistan, the president accused the Soviets of "appalling inhumanity" and of "violating human rights in the grossest kind of way."

Charging that the Soviets are interested only in expanding their "imperial objectives," Carter said:

"If the invasion of Afghanistan does indeed foreshadow a pattern of Soviet behavior for the next decade, then Americans must accept the truth that we are in for challenging and difficult times. In this ever more interdependent world, to assume that aggression need be met only when it is at one's own doorstep is to tempt new adventures and to risk new, very serious miscalculations. Our course is clear -- by responding firmly we seek to halt aggression where it takes place and to deter it elsewhere."

The administration's intensifying campaign to pressure the allies for greater support was emphasized even more last night in a speech to the editors by White House national security affairs adviser Zbigniew Brzezinski.

He acknowledged the positive role of allies in many areas of alliance concern, including agreement with the U.S. assessment of the danger of the Soviet move in Afghanistan and the necessity of a concerted response.

But, he stressed, "much as we welcome such declarations, we feel they that they should be accompanied by tangible measures."

Brzezinski warned that the NATO alliance was at a crucial turning point, and that "unless we prove ourselves capable of responding together" to the challenge that Soviet power poses to the vital interest of all the countries, both the alliance and "our common security will be imperiled."

In the present circumstances, Brzezinski said it was time that we and our allies asked ourselves "some searching questions."

"When Afghans are dying by the thousands," he asked, would it serve our interests or make sense to conduct business as usual with Moscow, subsidize Soviet military power by providing advantageous trade credits, sending high-technology equipment, or going to the Olympics?

Carter was one of three presidential candidates to appear before the edtiors yesterday. His Democratic rival, Sen. Edward M. Kennedy, (D-Mass.) said he hoped there can be a diplomatic settlement to the Iran crisis and that he will not second-guess the actions Carter has ordered.

Kennedy, who initially opposed a boycott of the Olympics, also declined to be drawn into controversy on that subject.

"The president has made a judgment about the boycotting of the Olympics and I will not take issue with that," he said.

Republican presidential hopeful Rep. John B. Anderson, asked what he would do as president to prevent a similar hostage situation, called for the United States to take the lead in convening all the governments of the world, "all 152 of them, and try to decide on the kind of concerted action" needed.

The creation of a standby force under the United Nations, he said, could be one possible mission of such a convention.

"To sit back and depend on the provisions of the Vienna Convention of, I think, 1952, is no longer adequate," he said, nothing that "even our closest allies in Europe are still hanging back and suggesting that the maintenance of their commercial relations with Iran is more important than upholding this very important principle."