The U.S. foreign trade deficit edged down slightly to $36.6 billion during the first three months of the year as a gigantic drop in petroleum imports offset price increases for other foreign goods, the government reported yesterday.

The Commerce Department said the trade deficit from January through March declined by 2.1 percent from a record quarterly deficit of $37.4 billion set from October through December.

The new report confirmed parallel figures released earlier that showed a higher deficit for the first three months of the year of $43.5 billion. The discrepancy exists because the new report, covering trade on a balance-of-payments basis, omits such factors as military sales and the cost of shipping and insurance.

Commerce Secretary Malcolm Baldrige cautioned against reading too much into the slight first-quarter improvement, noting that the deficit still was running at an annual rate of $146.3 billion. The deficit for all of 1985 was a record $124.4 billion.

Analysts attributed the slight improvement in the first-quarter trade deficit to a 29.1 percent plunge in the cost of imported petroleum, which came from a drop in oil prices and a decline in the volume of oil imported. The average price of oil fell to $21.56 a barrel in the first three months of the year from an average $26.30 a barrel in the fourth quarter, reflecting the dramatic drop in world oil prices.

But analysts said this improvement was only temporary because oil imports will start rising in coming months as refiners move to replenish inventories.