WASHINGTON (AP) _ The nation's 38.4 million Social Security recipients can count on a 4 percent increase in their benefits starting next January that will boost the average retired worker's pension by $21 a month, the government announced Friday.

The increase, the second largest in 6 1/2 years, will mean the typical benefit payment will go from $516 to $537 per month.

Offsetting the good news on benefit increases was a $7.10 hike in Medicare premiums, which will rise to $31.90 a month starting in January. They are deducted directly from the monthly benefits.

The exact size of the increase became official Friday when the Labor Department announced the latest change in the Consumer Price Index.

Since 1975, Social Security benefits have risen automatically each year with the CPI with the exception of six months in 1983 that were skipped to help bail the system out of a crisis.

The 4 percent increase, which will show up in the Jan. 3 benefit checks, followed a 4.2 percent increase which took effect last January. The two increases were the largest since a 7.4 percent rise in July 1982, back when high inflation rates translated into bigger cost-of-living hikes.

Social Security officials said the maximum monthly benefit for a worker retiring in 1988 at age 65 will rise $61, from $838 to $899.

The 4.5 million recipients of Supplemental Security Income, a welfare program for the aged, blind or disabled, also will get a 4 percent increase in their benefit payments.

The maximum federal SSI payment will rise by $14, from $354 to $368, for an individual, and by $21, from $532 to $553, for a poor couple.

The change in Social Security benefits is calculated by taking increases in the CPI for urban wage earners for the July-September period, compared with the same period in the previous year.

The agency gave the following examples of how the 4.0 percent increase will affect average monthly benefits:

-All retired workers, up $21, from $516 to $537.

-Aged couple, both getting benefits, up $38, from $883 to $921.

-Widowed mother and two children, up $42, from $1,070 to $1,112.

-Disabled worker, spouse and children, up $41, from $902 to $943.

-All disabled workers, up $20, from $509 to $529.

The Social Security Administration also announced that the maximum amount of wages subject to the payroll tax will climb from the current $45,000 to $48,000 in 1989. The wage base, the amount subject to the tax, has gone up every year since 1971.

The latest change means the maximum annual Social Security tax paid by high income workers will rise by $225.30 to $3,604.80. Employers pay the same amount each worker pays.

The change in the wage cap will affect about 9 million of the 130 million workers covered by Social Security.

The payroll tax rate will remain unchanged at 7.51 percent during 1989. But it will rise to 7.65 percent on Jan. 1, 1990, the final increase planned at this time. Those changes were adopted by Congress in 1983 as part of a bipartisan plan to bail the system out of recurrent financing problems.

Tax rates for the self-employed remain unchanged at 13.02 percent for 1989, but the amount subject to tax will rise to $48,000.

Social Security Commissioner Dorcas R. Hardy said the latest benefit increase ''ensures that America's elderly and disabled are able to maintain their purchasing power as the price of necessary goods and services rise.''

Officials said the cost-of-living increase will boost Social Security payments by $8.7 billion in 1989.

Here are some other changes for 1989 that the agency announced:

-Retirees ages 65-69 will be able to earn $8,880 without losing benefits, up from $8,400 currently.

-Beneficiaries under 65 will be able to earn $6,480 without penalty, up from $6,120.

-Workers will need to earn $500 for a quarter of coverage, up from $470.

Benefits are rounded down to the next dollar, which means most people wind up with an increase slightly smaller than the exact inflation rate.

Also, most SSI beneficiaries also get regular Social Security, and their entitlement to welfare benefits usually goes down when their Social Security check goes up.

Many economists contend that Social Security benefits will have to be curbed next year as part of a renewed effort by the next administration to reduce the country's huge budget deficits.

However, both Michael Dukakis and George Bush have competed with each other to assure voters that they will not touch Social Security benefits.