A spurt of automobile buying in December produced a strong finish for retail sales in 1987, but it was the weakest year for sales since 1982, the government said yesterday.

The Commerce Department said retail sales rose 0.7 percent in December to a seasonally adjusted $126.7 billion -- $900 million more than in November. It was the largest month-to-month gain since August, when car-buying bolstered by sales incentives pushed overall retail sales up by 1.5 percent.

For all of 1987, retail establishments sold $1.51 trillion in goods, or 3.5 percent more than in 1986. It was the weakest year-to-year growth since the 2.9 percent increase in 1982, a recession year.

Economists are expecting lackluster retail sales to continue this year, but they are hoping an increase in sales abroad will help keep the economy growing.

Department stores and other general merchandise stores sold 5 percent more in December than during the same month in 1986, another indication that the October stock market collapse failed to discourage Christmas shoppers.

White House spokesman Marlin Fitzwater called the report "good news," and Undersecretary of Commerce Robert Ortner said, "It would appear that the stock market crash was a nonevent, self-contained on Wall Street."

Car sales rose 2.4 percent in December, showing signs of recovery from the fall slump that came after dealer incentives expired at the end of the summer. In November, auto sales were down 0.7 percent

Michael K. Evans, president of the Evans Economics forecasting service in Washington, attributed the December increase in car sales to another round of incentives designed to attract buyers.

"We've gotten into a situation that without the incentives, sales are terrible," Evans said. "The improvement in December comes off very, very weak numbers in October and early November. Car sales aren't strong, they're just improved."

Excluding autos, retail sales rose 0.2 percent in December. In November, retail sales rose 0.3 percent.

Sales of durable goods were up 1.7 percent after rising 0.2 percent a month earlier.

Sales of nondurable goods rose 0.1 percent, matching the increase in November.

The overall growth in retail sales came mostly in the first eight months of 1987. Sales inched up 0.1 percent in November, after falling 0.9 percent in October and 1.7 percent in September.

Sales figures are adjusted to smooth out seasonal variations but do not exclude the effect of rising prices. The 3.5 percent increase in 1987 did not keep pace with the consumer price index, which rose at an annual rate of 4.7 percent for the first 11 months of the year.

The 1987 sales increase compared with a 5.4 percent rise in 1986, 7 percent in 1985, 10.1 percent in 1984 and 9.5 percent in 1983.

The Commerce Department also reported that in December:

Sales at department and other general merchandise stores were down 0.4 percent after no change in November.

Furniture and home furnishing sales were down 0.5 percent after a 0.2 percent increase in November.

Sales at building-supply and hardware stores were up 1.3 percent after a 1.1 percent drop in November.

Grocery and other food stores reported sales were up 0.5 percent, compared with a 0.1 percent decline in November.

Sales at restaurants and bars were up 0.8 percent after a 1.5 percent increase the month before.

Clothing stores reported a 0.3 percent increase in sales, drug stores were down 0.3 percent and gasoline stations were down 1.1 percent.