The nation's 38 million Social Security recipients will get a 4.2 percent cost-of-living increase in benefits for 1988, the Social Security Administration announced yesterday.

Retired workers also will be allowed to earn more next year without any reduction of benefits, officials said. But workers and self-employed people will have to pay more Social Security taxes out of each paycheck.

The cost-of-living increase, the largest since 1982, will boost the average monthly retirement benefit for a single person by $21, to $513.

For an aged couple, the average increase will be $35, to $876. For a widow, the average monthly benefit will rise from $449 to $468, and for a widow with two children it will rise from $1,034 to $1,077.

The average for a disabled person with a spouse and child will rise from $882 to $919.

For a person retiring in 1988 at the age of 65, the maximum monthly benefit will rise to $838. A person retiring at the maximum in 1987 got $789 initially and after the cost-of-living increase will get $822 a month in 1988. Officials said the 1988 retirees will receive more because in their final year of work the workers were subject to Social Security payroll taxes on a higher amount of income than the 1987 retirees were in their last year.

Under law, Social Security benefits as well as the maximum wage subject to the Social Security tax and the maximum earnings allowed beneficiaries are automatically raised each year to keep pace with inflation and economy-wide changes in wages. For 1987, for example, the cost-of-living increase was 1.3 percent. The announcement of the 4.2 percent benefit raise was tied to the Labor Department's report yesterday on the fiscal 1987 Consumer Price Index.

The 4.2 percent hike will appear in checks to be received Dec. 31 because the usual payment date, Jan. 3, falls on a Sunday.

Similar 4.2 percent increases will be received by:About 4 million low-income aged, blind and disabled persons who receive benefits under the federal Supplemental Security Income (SSI) program. As a result of this increase, the maximum federal SSI benefit for a person with no other income will rise from $340 a month to $354 a month, and for a couple from $510 to $532.

About 3.6 million former federal civilian and military employes who get civil service and military retirement pensions.

Low-income persons receiving veterans' pensions not based on service-connected disabilities.

Retired railroad workers on the portion of their railroad retirement benefits linked to Social Security.

In addition to the benefit increases, the Social Security Administration announced these payroll tax and earnings changes:The maximum amount of wages subject to the Social Security tax will rise from $43,800 a year to $45,000. Out of a national workforce of 126 million, about 9 million workers now earn more than $43,800, officials said.

The tax rate, at 7.15 percent each for employers and employes this year, will rise to 7.51 percent under legislation passed in 1983. As a result, the maximum Social Security tax on any worker will rise to $3,379.50 in 1988. A person with average earnings -- about $18,135 in 1987 -- would pay an estimated $1,362.

For self-employed people, the net tax under the 1983 law will rise to 13.02 percent, compared with 12.3 percent this year. A person with the maximum taxable self-employment income of $45,000 would pay $5,859.

The amount of earnings from a job that a person under 65 can have without reduction of Social Security benefits will rise from $6,000 this year to $6,120 in 1988.

For a person 65 to 69, permitted earnings will rise from $8,160 to $8,400. For persons 70 or over, there is no limit.

In the Medicare program, the monthly premium for coverage under the doctor-insurance portion of the program (Part B) will rise from $17.90 this year to $24.80 in 1988. The amount a Medicare patient must pay to cover the first day of hospitalization (the next 59 are free) will rise $20 to $540.