Iran's political upheaval will prompt Saudi Arabia, Mexico, Kuwait and other oil exporters to restrict future production, pressing the United States toward a severe energy shortage in the next two to six years, Deputy Energy Secretary John F. O'Leary has warned.

Laying Shah Mohammad Reza Pahlavi's fall from power to "perceived excesses" and "squandering the national patrimony," O'Leary said it is "inevitable" that other major oil exporters will adopt conservative production policies. Consequently, the second-ranking energy official said world oil supplies will tighten between 1981 and 1985.

"We're going to need [to have] a lot of energy, or we're going to suffer," O'Leary told reporters yesterday. Asked about preparedness to deal with the Energy Department's off-predicted oil crisis, the deputy secretary said, "We're not in very good shape."

Later yesterday in testimony before a House subcommittee, another DOE official, Harry E. Bergold Jr., said the United States has received "informal statements of intention" that Iran will resume shipments of oil to the United States. Bergold's testimony came on the heels of a statement by Assistant Secretary of State Harold Saunders that as soon as Ayatollah Ruhollah Khomeini and his followers are able to organize a new government, they would likely have "as much interest in exporting oil" as the shah did.

Energy and State Department officials, however, are still cautious in forecasting the return of Iranian production, and O'Leary and Energy Secretary James R. Schlesinger have both said Iranian production will probably not exceed 4 million barrels a day again. Before the political turmoil, Iran produced as much as 6.5 million barrels of oil a day.

Calling the Iranian shutdown a "foretaste" of what he believes will be increasingly conservative production policies among the oil exporters, O'Leary says that Iran's revolution means "the disappearance of the chronic surpluses that have dominated the oil market."

O'Leary also argued against "mythic reliance on Mexico or Saudi largess" to help the industrial nations avoid a shortage.

Together, Central Intelligence Agency and major oil company analysts have been saying that Mexico and Saudi Arabia could produce 10 million and 20 million barrels a day respectively by 1990 if they chose to. Today, as the world's leading exporter, Saudi Arabia is producing nearly 10 million barrels a day, and newly oil-rich Mexico, fewer than 2 million.

Until Iran's political turmoil began months ago, world oil markets had been glutted by a surplus of as much as 2 million to 3 million barrels a day. World consumption is now running slightly more than 50 million barrels of oil a day.

The CIA oil forecast President Carter made public in April 1977 as he unveiled his energy plan did not foretell the so-called oil glut, and also did not disclose then-classified intelligence that Mexico had as much as 140 billion barrels that could be produced.

Schlesinger now says that Saudi Arabia, the world's "swing producer," will not likely be producing more than 12 million barrels of oil a day by 1985, and that Mexico will pursue a restrained production policy.

Other government analysts, however, suggest that the Organization of Petroleum Exporting Countries and Mexico could be under stiff political and economic pressures to produce in the 1980s that would tend to stave off a crisis.

In related energy developments yesterday:

DOE called on motorists to report suspected price gouging by oil companies that could result from the Iranian situation on the department's toll-free hot-line (254-5474 locally and 800 -- 424-9246 outside the Washington area).

Illinois gasoline dealers have been requested to close Sundays, starting Feb. 25, by the 3,700-member Illinois Gasoline Retailers Association.

The Independent Gasoline Marketers Council, representing dealers in 45 states, filed suit in federal court to bar DOE from implementing emergency oil allocation rules, charging that the department's new rules are "unlawful, arbitrary and capricious."

Standard Oil Co. of California joined other major oil companies, including Shell and Texaco, when it was granted permission by DOE to begin allocating oil to its dealers.