America's balance-of-payments account showed the largest deficit in four years during the third quarter, the Commerce Department reported yesterday.

The balance of payments was driven into the red when the merchandise trade deficit more than doubled to a record high $12.5 billion. The balance of payments deficit totaled $4.2 billion, compared with a $2.2 billion surplus in the second quarter.

The record-high merchandise trade deficit received the major blame for shifting what had been a balance-of-payments surplus into the red-ink column. The merchandise trade deficit was $5.7 billion in the second quarter of this year. The previous record high deficit in merchandise trade was $11.1 billion in the first quarter of 1978.

The Commerce Department said most of the growth of the merchandise trade deficit between the second and third quarters was accounted for by a $3 billion increase in petroleum imports and a $2.2 billion decrease in agricultural exports. The increase in oil imports followed four straight quarters of declines.

While the merchandise trade continued its record of constant deficits since 1975, services sold by the United States overseas such as transportation, banking and insurance , grew slightly. The third-quarter trade surplus in services totaled $10 billion, an increase of $200 million from the second quarter.

These surpluses in international services have been carrying the nation's trade balances, but they are not expected to be strong enough in the coming quarters to overcome the growing merchandise trade deficits, which on an annual basis are heading toward a record $40 billion for this year.

Some economists blamed the strong American dollar for the growing trade gap, which is expected to increase even more next year.

"It's almost wholly due to the strong dollar," said C. Fred Bergsten, a former Carter administration treasury official who is director of the Institute for International Economics.

The Commerce Department's Bureau of Economic Analysis said the U.S. dollar gained 5 percent in the third quarter in comparison with the currencies of 10 other industrialized nations.

The Commerce Department reported that the trade deficit for the first three quarters of 1982 was $920 million, but anticipated deficits in the final quarter are expected to make the balance-of-payments picture even worse.