Japan recorded a surplus of $3.71 billion in its trade with the United States in October, second only to the $3.78 billion surplus in September, the Finance Ministry announced yesterday in Tokyo.

In trade with all nations, Japan's total surplus was $4.41 billion in October, bigger than the $3.59 billion surplus in October 1984 but well below the monthly record of $5.02 billion posted this July. The surplus in September was $4.55 billion.

Overall October exports totaled a record $16.02 billion, up 7.4 percent from a year ago, while imports were $11.61 billion, up 2.6 percent. The previous export record of $15.9 billion was set last December.

Japan's exports to the United States climbed 9.2 percent from October 1984 to $6.03 billion, while imports from the United States rose 1.6 percent to $2.32 billion.

Japanese car exports to the United States climbed 36.4 percent from October 1984 to $1.58 billion, maintaining a trend that began in April with a substantial easing of restrictions on car shipments to the U.S. market.

But because of new restraints that Japan imposed at Washington's request, Japanese steel exports to the United States fell 33.5 percent to $182.49 million in October.

Imports of U.S. aircraft soared 285.3 percent from a year ago to $202.87 million.