The United States merchandise trade deficit fell last year by $3.7 billion to $24.7 billion, despite a $17.2 billion jump in the cost of oil imports, the Commerce Department reported yesterday.

Separately, administration officials said the United States would show a slight surplus for 1979 in its transactions with other countries when trade in services, travel, investment income and some other transfers are counted along with merchandise trade. This more comprehensive measure is known as the balance on current account.

In December, however, the merchandise trade deficit widened to $3.1 billion from $1.4 billion the month before, largely because of a $1.3 billion increase in oil imports.

The volume of oil imports was unusually low, and the increased oil cost was due to a rebound in imports and a higher per-barrel cost reflecting the latest round of OPEC price hikes.

During 1979 the value of U.S. exports rose 26.5 percent to $181.6 billion, while imports rose 19.9 percent to $206.3 billion.

The United States trade deficit with the OPEC nations widened from $14 billon in 1978 to $27 billion last year. With the latest increases, administration officials expect another large increase in the deficit with OPEC this year.

Except for other transactions involving oil imports, such as from Mexico and the Caribbean, the U.S. trade balance generally improved.

The deficit with Japan fell from $11.7 billion in 1978 to $8.7 billion in 1979. The deficit in trade with West Germany dropped from $3 billion to $2.5 billion. The $5 billion deficit with Canada was virtually unchanged.

Because of the deficit with OPEC, the United States deficit with developing nations widened from $18.9 billion to $29.3 billion. On the other hand, the 1978 deficit of $13.3 billion with other developed countries was trimmed all the way to $900 million.

Officials said the improvement in the trade balance with developed countries was the result of relatively slower economic growth in the United States than abroad, and of the decline in the value of the dollar during 1977 and 1978.

Most analysts expect the merchandise trade deficit to grow again in 1980 because of the higher cost of oil.In December the average price of imported oil was only $24.80, up $1.67 from November, but still well below the current $30 or more being charged for oil including transportation.

However, the large U.S. surplus in services and the other items that make up the balance on current account is forecast to grow almost as rapidly. While the current account balance probably will turn negative again in 1980, it will be by a narrow margin, analysts said, at a time other industrial countries will be registering large current account deficits because of oil.

In December the United States had a $1.7 billion surplus in trade in agricultural commodities and a $370 million surplus in manufactured goods. The deficit in oil products was $6.6 billion.

If the cost of imports is calculated to include transportation and insurance, the December deficit is larger, $4.2 billion. On that basis, the deficit for all of 1979 was $39.5 billion. The cost of transportation and insurance are two items included in the balance on current account.