The U.S. foreign trade deficit widened in October to $2.13 billion, a surprising reversal of the gradual improvement that had occurred during the summer and early fall, the government reported yesterday.

News of the deficit, which compared with $1.69 billion in September, sent the dollar falling temporarily on the foreign exchange markets. However, the U.S. currency later stabilized and began recovering in some markets.

Treasury Secretary W. Michael Blumenthal said the disappointing figures reflected temporary factors - primarily a sharp dropoff in gold exports - and did not change the outlook for further improvement in coming months.

The United States now is expected to post a record trade deficit for the year, reaching $28 billion to $30 billion, compared to last year's record of $26.5 billion. But Blumenthal said yesterday's figures point to "continued progress" toward reducing the deficit.

The Commerce Department reported separately that its index of leading economic indicators, whose behavior is supposed to presage changes in the economy, rose 0.5 percent in October, signaling further growth ahead.

Meanwhile, the Labor Department said that the productivity of American workers, a key factor in dampening inflation, rose at only a 3.4 percent pace last quarter, instead of the 4.5 percent rate recorded in a preliminary estimate previously.

The revised increase means business costs were pushed up more sharply, intensifying pressures on companies to increase prices. Unit labor costs rose at a 6.7 percent pace last quarter, rather than 5.1 percent, as reported before.

The figures came as President Carter declared yesterday that the recent strengthening of the dollar had relived pressure on the oil-producing nations for a higher price rise next year, making a 5 percent boost likely.

Carter told a group at the Democratic National Committee yesterday the recent firming of the dollar "will be a major factor" when the issue comes up at a meeting of oil ministers next month.

There also were these related developments.

The Securities and Exchange Commission announced it will require publicly held corporations to report any impact from Carter's wage-price guidelines program, including losses stemming from government sanctions or squeezing of profits.

The nation's purchasing agents, whose attitudes often are a barometer of inflation psychology, indicated in a survey they expect a mild recession next year and are less optimistic than before about slowing inflation.

Federal Reserve Board Chairman G. William Miller said he believes it is possible that Carter will be able to balance the budget by 1981 or 1982, but warned the fight against inflation will require sacrifices by everyone.

The worsening in the trade deficit last month stemmed primarily from a sharp drop in exports. Export levels plunged 3.1 percent, or $418.4 million, in October in their sharpest decline since last January.

By contrast, imports remained essentially stable over the month, rising a scant 0.1 percent, or $18 million.

However, officials said the bulk of the drop in exports came from a $415 million decline in U.S. shipments of gold for industrial and jewelry uses, following an usually large jump previous month.

Farm exports also declined slightly. However, these are erratic and vary widely from month to month.

Perhaps even more interesting were two key developments on the import side:

Petroleum imports fell 3.5 percent in October to a new level of $3.5 billion, offsetting part of an 8.1 percent jump recorded in September.

At the same time, steel imports rose a sharp 8.3 percent to a new level of 1.7 million tons, despite imposition of the administration's new trigger price" plan designed to hold back foreign-made steel.

Analysts had no immediate explanation for either development. However, the figures on steel were expected to send domestic steel producers protesting to Washington again. Most have been lukewarm over the new program.

The October trade deficit, the 29th in a row that the nation has posted, followed red-ink figures of $2.99 billion in July, $1.62 billion in August and $1.69 billion in September.

In the index of leading indicators, five of the 10 indicators available showed improvement in October, while the other five declined. The major influence on the index was a sharp rise in orders for new plant and equipment.

Improvement in the nation's trade posture is important because the size of the deficit has been a major factor in the decline of the dollar. A dip in the dollar's value abroad in turn worsens inflation here.

The October figures brought the cumulative trade deficit for the first 10 months of the year to $24.79 billion. By contrast, last year at this time it was $21.16 billion.