The federal government posted a rare surplus of $16.09 billion last month, primarily because Social Security checks for January were mailed early, the Treasury Department said yesterday.

The government reported a deficit of $24.22 billion in December.

The January surplus, the first since September, occurred because Social Security checks, which normally go out on the third day of the month, were mailed Dec. 31 because of New Year's holiday. The early payment inflated spending in December and lowered spending in January.

For the first four months of the fiscal year, which began Oct. 1, the monthly deficits have totaled $65.81 billion, down 0.7 percent from the same period in the 1987 fiscal year.

For all of 1988, the Reagan administration is projecting that the budget deficit will fall to $146.74 billion, down 2.5 percent from last year's deficit of $150.4 billion.

However, the Congressional Budget Office, using less optimistic assumptions about economic growth this year, projects a 1988 deficit of $157 billion, well above the target of $144 billion set in the Gramm-Rudman deficit reduction law.

Last Thursday, President Reagan sent Congress his budget recommendations for 1989, in which he asked for $1.1 trillion in federal spending and forecast that the deficit next year would drop to $129.5 billion.

For the first four months of this fiscal year, revenue has totaled $286.66 billion, 5.5 percent higher than a year ago. Government spending totaled $352.46 billion, up 4.2 percent over the same period a year ago.

In January, government revenue totaled $81.79 billion, down 4.3 percent from December. Government spending was almost half the December total, dropping to $65.71 billion in January, compared with $109.74 billion the month before.

As usual, the largest spending category in January was the military, followed by Social Security, other programs in the Department of Health and Human Services and interest on the national debt.

Military spending totaled $19.23 billion last month and $93.52 billion for the fiscal year so far, up 6.5 percent from the same period a year ago. Spending for Social Security totaled just $652 million last month.

The other programs in the Department of Health and Human Services, including Medicare and Medicaid, spent $50.51 billion in January and $49.93 billion so far this budget year, a 1.1 percent increase over 1987.

Interest on the $2.2 trillion national debt totaled $14.67 billion last month and $75.77 billion so far this fiscal year, an increase of 9.8 percent over the same period last year.

For the 1988 fiscal year, interest payments on the debt are expected to total $210.06 billion, accounting for 20 percent of total federal spending.