President Carter yesterday promised Japanese Prime Minister Masayoshi Ohira that the United States will be helpful if a shutoff of Iranian oil causes trouble for Japan.

Carter made the statement, according to White House officials, in a two-hour working luncheon. It was the first meeting between Carter and a senior allied leader since the aborted rescue raid in Iran last week and the resignation of Cyrus R. Vance as secretary of state.

From all outward signs, both Americans and Japanese, the working visit by Ohira was unaffected by the turbulent events of recent days.

Ohira praised Carter's "patience and restraint" in the Iran situation, which is an understated Japanese way of asking that those qualities carry into the future. The Japanese have been apprehensive about U.S. military action, which would threaten the flow of oil from the Persian Gulf.

Partly as a measure of support for the United States, Japan refused to go along with a new price increase demanded by the new Tehran government two weeks ago. As a result, Iran shut off petroleum shipments to Japan -- roughly 520,000 barrels per day, or 10 percent of the country's crude oil imports, according to Japanese officials.

Japan is seeking to make up the shortfall by a combination of conservation measures, reduction of its oil stockpile and acquisition of additional petroleum elsewhere on the world market.

In this context Carter's pledge to be "helpful" in a pinch appeared to be Washington's way of reassuring the Japanese and encouraging continued solidarity. U.S. officials said no decision has been made on the details of U.S. help, and that there was no discussion with Ohira about a possible supply of Alaskan oil.

The officials suggested that a likely form of U.S. aid -- if the Japanese need and request it -- is diplomatic action to facilitate Japan's application for assistance under the International Energy Agency arrangement for sharing major oil shortages among consuming nations. Japan is probably eligible for assistance under this arrangement, but it is unclear whether a request will be made by Tokyo.

Carter, in a Rose Garden exchange of remarks, said "remarkable progress" had been made in U.S.-Japanese relations in the past year. The president said Japan's decisions had been "the right ones" and that the relationship with Tokyo is "the cornerstone of policy" for the United States in Asia.

Ohira said "Japan stands ready to demonstrate her solidarity with the United States" in the Iranian situation and will continue to assist the United States and other allies in seeking to counter the Soviet Union's invasion of Afghanistan.

Speaking in English sentences, which he had practiced diligently in preparation for the visit, Ohira said, "We, the Japanese, may not be the most eloquent, but we remain a determined and one of the most dependable friends of your country."

There was no indication of substantive progress on the range of economic issues involving the import of Japanese automobiles, which now claim about one-fourth of the U.S. market. But U.S. participants in the White House meeting said Carter spoke at length of his "deep concern" about the domestic impact of the auto imports, and that Ohira appeared to be receptive.

According to this account, important progress is expected in the trip to Tokyo starting May 10 of U.S. special trade representative Reuben Askew.

Among the items under discussion are Japanese investments in automobile plants and replacement parts facilities in the United States, and reduction of Japanese import barriers to American automobile sales.