WASHINGTON (AP) _ President Reagan on Friday signed legislation designed to end the dumping of sewage sludge in the ocean by 1992.

The bill is aimed at closing the nation's last remaining sludge dumping site, some 106 miles off the New Jersey coast.

The only agencies affected by the new legislation are three regional sewage authorities in New York, including New York City, and six authorities in northern New Jersey.

No other jurisdiction in the nation still dumps its sludge at sea.

Under the measure, the agencies must end their dumping by Dec. 31, 1991, or pay stiff penalties amounting potentially to millions of dollars.

Meanwhile, the dumpers will begin next year to pay increased fees, separate from potential penalties, for use of the ocean as a dump site.

Both the fees and fines, if needed, will be pooled to help develop alternate disposal methods.

Reagan's signing of the bill, without comment, climaxes a 10-year legislative effort to halt the dumping. Congress voted a first ban in 1978, effective in 1981, which was successfully challenged in federal court by New York. The dumping has continued under court authority since.

New York lawmakers and New York Mayor Edward I. Koch opposed the new measure, but ultimately agreed to a compromise in the face of mounting congressional pressure.

''Ocean dumping is one of the most insidious forms of pollution ever inflicted on the environment,'' said Rep. William Hughes, D-N.J., the principal author of the bill, after it was signed into law.

''We're taking big strides in our effort to clean up the ocean,'' added Sen. Frank Lautenberg, D-N.J., the chief Senate sponsor.

Sen. John Chafee, R-R.I., said, ''The environmental health of the oceans and the economic health of the fishing industry demand that we end the dumping.''