Undated (AP) _ OPEC agreed today to cut oil production and raise prices, which could help boost the cost of living in the United States after a year the Labor Department says will end with the lowest annual inflation in more than two decades.

All members of the Organization of Petroleum Exporting Countries except Iraq agreed in Geneva to cut production by 7 pecent and establish a unified price system averaging $18 a barrel. Oil prices now range from $13 to $16 a barrel.

The Labor Department said Friday that prices in the United States were up 0.3 percent in November, as higher food and automobile prices offset marginally lower energy costs.

With the year nearly over, inflation for all of 1986 will probably finish at or slightly under 1.3 percent, which would be the lowest annual rate in 22 years, the department said.

The record low, however, is almost completely due to the precipitous drop in world oil prices early this year. Economic analysts both inside and outside the government predict that inflation will rise next year to about 4 percent, close to the level that prevailed before oil prices plunged in early 1986.

One item reflecting the low inflation level has been gasoline. During the Christmas holiday season, for example, motorists probably will find gasoline prices unchanged from Thanksgiving and around 35 cents a gallon lower than prices a year ago, the American Automobile Association said Friday.

Gasoline prices at the pump average 90.4 cents a gallon compared with $1.256 during last Christmas, according to an AAA survey of 6,000 gas stations.

The OPEC accord to reduce crude oil output is expected to drive energy prices higher in the coming months.

The energy ministers of Mexico and Norway said they would cooperate with OPEC producers to achieve world oil price stability once the cartel's 13 members agreed among themselves to reduce output.

Oil prices rose sharply Thursday after Saudi Arabia and Iran abandoned their attempt to force Iraq to participate in the reductions, and the trend continued Friday. On the New York Mercantile Exchange, contracts for January delivery of West Texas Intermediate, the benchmark U.S. crude oil, closed at $16.21 a barrel, up 15 cents from Thursday's close.

In other economic news Friday:

-The Treasury Department said the federal budget deficit last month was $27 billion, a fall of 19.1 percent from its November 1985 level. The Reagan administration predicts that the 1986 deficit will probably reach $163 billion, well over the ceiling target set up in the Gramm-Rudman deficit reduction law but below the record $220.7 billion deficit registered in the fiscal year ended Sept. 30.

-The Labor Department reported that U.S. average weekly earnings increased 0.8 percent last month after adjusting for inflation, the best performance in eight months.