Nearly 37 million Social Security beneficiaries will receive a 3.1 percent cost-of-living increase starting Jan. 3, the government announced yesterday.

Spokesmen for the Pentagon and the Office of Personnel Management said that similar increases will go to approximately 1.5 million retired military personnel and 1.9 million retired federal employes or their survivors, unless Congress changes existing law. Related story, Page D2.

An Office of Management and Budget spokesman said that because inflation turned out to be lower than had been anticipated in budget projections earlier this year, the cost-of-living increase will cost the government about $1 billion less than had been projected.

In addition, Health and Human Services Secretary Margaret M. Heckler announced that the Social Security payroll tax also will rise, to a maximum of $3,003 for work- ers earning $42,000 or more in 1986.

The automatic annual Social Security benefit increase, first authorized by 1972 amendments, is designed to cover inflation in the cost of consumer items in the year that ended Sept. 30. It is paid whenever the increase in the Consumer Price Index from the third quarter of one year to the third quarter of the next is 3 percent or more.

The increases in benefits for retired military and retired federal employes, plus certain increases for veterans, are triggered by similar legal provisions.

With the new increase, monthly Social Security payments to a person who retired in 1985 at age 65 with the maximum benefit will rise on Jan. 3 from $717 to $739. For a person retiring at 65 in 1986 with the maximum benefit, the monthly payment will be $760, reflecting changes in average wages, differ- ent work-year bases and similar factors.

Most workers, however, do not receive the maximum. The average benefit for all retired workers this year is $464 a month, which will rise to $478 in January. The average benefit for a retired couple, now $788, will rise to $812; for an elderly widow, from $419 to $431, and for all disabled workers, from $469 to $483.

In addition to the Social Security cost-of-living increase, Heckler announced these other changes required by law:

*A 3.1 percent increase also will be paid, starting with checks received Dec. 31 of this year, to about 4 million recipients of Supplemental Security Income (SSI), the federal welfare program for low-income elderly, blind and disabled persons. As a result, the maximum SSI payment to an individual without other income will rise from $325 a month to $336; for a couple, from $488 to $504.

*The Social Security payroll tax, now 7.05 percent each for workers and their employers on the first $39,600 earned by the worker, will rise to 7.15 percent each and will be levied on the first $42,000 of wages. For a worker making $10,000, the change will boost the Social Security tax by only $10 a year, to $715. The employer would pay a similar increase. But for a worker earning $42,000 or more, the current tax of $2,791.80 will rise to $3,003, as will the employer's contribution.

*For self-employed persons, the maximum effective tax will rise to 12.3 percent on the first $42,000 of self-employment income, or $5,166 in 1986. At present, the effective rate is 11.8 percent on the first $39,600.

*The maximum wages that a person may earn without any reduction in Social Security benefits will rise from $5,400 this year to $5,760 in 1986 for persons under 65. For those 65 through 69, the amount will increase from $7,320 to $7,800. There is no limit for persons over 69.

The Social Security Administration estimated that the cost-of-living increase will add $5.8 billion in 1986 to the costs of the system. Even so, the total income of the system should be $203.4 bil- lion in calendar 1986, and outlays $198.2 billion, so there should be a surplus of $5.2 billion for the year.