The world's leading industrial nations agreed today to take wide-ranging measures aimed at cutting international oil demand by 5 percent in a bid to head off world-wide shortages and new price hikes for oil exports in the wake of the Iranian crisis.

The 20-nation International Energy Agency said that each member country would cut consumption or find other energy to meet the 5 percent quota and cover a projected shortfall in oil supplies of 2 million barrels a day in 1979, as reported earlier in the Washington Post. The reduction in oil demand is expected to stay in effect next year, conference sources said.

The United States, often criticized by other industrial nations for failing to curb its oil imports, undertook to reduce its oil needs by nearly 1 million barrels a day. This saving, nearly half the IEA objective, apparently will be achieved largely by cutbacks in consumption and stockpiling -- including some mandatory restrictions on heating and driving -- but not gasoline rationing, U.S. delegation sources said.

Although the thrust of the IEA resolution is to cut reliance by industrial nations on imports from the Organization of Petroleum Exporting Countries (OPEC), the complex final wording calls for demand restraint in relation to each country's consumption, not its imports. This phrasing was designed to insure that the United States, which imports only half its oil, carried a share of the burden equal to countries like Japan and West Germany, which must import all their oil, conference sources said.

To meet the IEA guidelines, individual countries will adopt a mixture of methods: cutting consumption, switching to non-oil fuels, boosting domestic production of oil and gas or relaxing regulatory standards to reduce oil stockpiles and allow use of lower-quality fuel.

Some countries can meet the target promptly: Canada announced late today that it had boosted oil production, and Britain has facilities for switching from oil to coal for electricity generation.

The United States, which will rely mainly on consumption cuts and clearly hopes to use the IEA commitment as leverage to help President Carter's energy-saving program, plans to have its conservation measures in effect by late 1979, according to Richard Cooper, under secretary of state for economic affairs. Carter has under consideration a list of 40 recommendations, mostly mandatory, and he will announce the U.S. oil-saving program "in a few days," U.S. officials said.

West Germany reportedly intends to rely partly on a policy of passing along price increases to customers in order to drive down demand, and a West German official said that he foresaw no need for stiffer measures like the "non-driving days" during the 1973 oil crisis. France, although not an IEA member, intends to comply, officials said.

IEA Chairman Nils Ersboll of Denmark said that the IEA governing board judged that the oil supply situation was "sufficiently serious" for prompt, united action. Even if Iranian production started recovering, IEA officials said, there was no guarantee that other oil-exporting states could sustain their current level of extra output. The 5 percent target was designed to prevent shortages next winter, they said, and was also to undercut the steep price rises in the spotmarket for crude oil.

The IEA program is flexible in its range of options so countries have leeway to protect their economic performance, conference sources said. "We don't want to thwart the growth of West Germany or Japan," Cooper said. Japan is able to meet the IEA target with an energy conservation program which it adopted last month, officials said.

But West Germany agreed to cooperate only after initial reservations about the possibility of an economic slowdown if it was obliged to cut oil imports significantly, conference sources said.

On the other hand, West German delegates said that they were gratified that other governments particularly the United States, were starting to recognize that the Iranian crisis had highlighted an underlying permanent problem of over-dependence on OPEC oil. The United States, for instance, lost only about 600,000 barrels a day in Iranian oil, but the IEA program obliges the United States to cut back its oil demand by nearly 1 million barrels a day.

IEA officials, together with the U.S. delegation, said that they viewed the IEA program as a positive response to Saudi Arabia's recent call for consultations between oil importing and exporting countries. Saudi Arabia will be briefed fully on IEA intentions by Ersboll, current IEA chairman, officials said. U.S. officials said that Washington supported these informal contacts with producers rather than a full-scale conference liable to bog down in other issues.

OPEC will welcome the IEA bid to curb oil consumption, industry sources said, because the main oil-exporting states consistently have urged conservation.