Legislation is needed to prevent the sale of public-housing units to upper-income buyers five years from now, Rep. Barney Frank (D-Mass.), chairman of the House Government Operations Committee's housing subcommittee, said this week.

The Department of Housing and Urban Development has just launched a trial program in which public-housing authorities in more than 20 U.S. communities will sell about 2,000 units to the low-income families living in them, using financial aid from local and state governments and "technical assistance" from HUD. Under the HUD guidelines, the new owners can resell their homes in five years at any profit the market will allow, unless local housing authorities place caps on resale prices.

"Everyone is in favor of home ownership," Frank said. But he, other subcommittee members and witnesses said at a hearing that shortcomings in the current HUD demonstration could lead to depletion of the nation's low-income housing stock, leaving the poorest families and shabbiest units in government ownership, and windfall profits for owners who resell their homes.

The possible drop in available housing is "something we will want to address with legislation," Frank said.

One witness questioned the administration's motives. Bernard Tetreault, who is executive director of the Montgomery County Housing Opportunities Commission -- which administers low-income housing there -- and a representative of the National Association of Housing and Redevelopment Officials, called the present demonstration "another veiled attempt at abandoning the federal government's almost 50-year commitment to provide low-income housing." He said HUD "has not asked for funding to replace those units that will be removed from the supply of rental housing in the demonstration cities."

The department has "a long-term commitment to public housing," replied June Q. Koch, assistant secretary for Policy Development and Research. She cited President Reagan's desire "to encourage residents of public housing to move toward home ownership. We think it supplies stability and rootedness . . . and will have an impact on the whole public-housing neighborhood. . . ." The sales program will enhance HUD's "overall efforts to improve public housing," she added.

Several witnesses and legislators urged measures to forestall loss of single-family homes and apartments from the housing stock. The demand for public housing already is greater than the supply, with waiting lists in many areas so long that families will not get homes for another 10 to 20 years, Tetreault said.

In addition, low-income tenants who become homeowners and then resell the units should not benefit from "windfall" profits -- the difference between the below-market price at which they bought the house and the market price at the time of the sale, Frank said. All the housing authorities taking part in the trial will sell units to the tenants at prices far below the market levels. In Lowell, Mass., for example, sale prices will range from zero to $20,000, depending on family income.

Frank proposed that a distinction be made between the value of the equity owners build up in their homes and the windfall profit. The windfall money "probably should be recaptured and used for other purposes" by housing authorities, he said.

Legislators and several witnesses were most worried, however, that when homes and apartments are resold at prices low-income families cannot afford, the units thus lost to the housing stock will not be replaced. Eventually, all 2,000 units in the HUD demonstration program could be sold off, Frank said.

He and several witnesses said replacement units should be ready "at the point of the second sale," when homes are likely to be sold at market rates low-income buyers cannot meet.

Lengthy waiting lists for public housing in many areas of the country are indications that shortage is already a serious problem, witnesses said.

"A low-income family applying for housing today in Baltimore may reach the top of the waiting list in 1993, while in New York City the wait may reach 20 years," said Tetreault, of the Montgomery County housing authority. He said that, according to the local Council of Governments, about 34,000 families are waiting for public housing in the Washington metropolitan area.

Koch sought to counter the fear that the ownership program will further deplete the low-income housing supply. Many local housing authorities selling units in the current trial will lengthen the time before homes can be resold at market rates, and use other ways to "deal with resale" of units to keep them within the economic reach of poor families, she said.

"There is something of a dilemma. We do not want sales to lead to windfall profits, but if you're selling . . . there has to be some equity build-up . . . . So there has to be a working out of arrangements to satisfy those needs," Koch added.

She said HUD's experience with other public-housing ownership programs has been "mixed" and that "we really don't know what conclusions to draw from it." Only a minority of the units authorized for sale under two past programs actually were sold, but "there's not a lot of data on why," she said.

Rep. Howard C. Nielson (R-Utah) questioned whether another ownership plan, known as the 235 program, under which HUD provides mortgage insurance and interest subsidies for low- and moderate-income home buyers, is a better method than HUD's present demonstration. The housing authority in Provo, Utah, which Nielson described as "probably one of the most conservative towns in the country," likes the 235 program but opposes HUD's present plan, he said.

Koch, however, described the program as a scandal-ridden "disaster."

HUD "terminated" the 235 assistance program in 1983, but Congress reactivated it in the same year, authorizing $150 million for 5,400 mortgages, according to a department spokesman. About half of the money has been used, and the remainder will be used by the end of the year, he said.

In the current program, sales of public-housing units are likely to skim off the best homes and apartments, leaving the shabbier units for tenants who do not want to buy or cannot buy their homes, Frank said. This has been part of a major argument against public-housing sales by other critics, who predict the best-built and -maintained units will go to the tenants with the highest incomes and who are the most stable. The resulting stock of government-owned housing will include only the lowest-quality units and will be inhabited by the poorest households, according to this argument.

People who cannot afford to buy make up the large majority of public-housing residents, according to Doris Bunte, administrator of the Boston Housing Authority, the fourth-largest in the nation. Home ownership, as offered by HUD in the present trials, "would make sense for only a minute number of public-housing tenants in Boston," where the average per-capita income of residents in the housing authority's developments last year was $2,156 annually, Bunte said.

Housing authorities already have legislative authority to sell public-housing units, but tenants cannot buy their homes unless the housing authority agrees.

Legislation has been introduced in Congress "that will give tenants directly the right to buy, bypassing the housing authority," Koch said. The housing authorities already taking part in the demonstration favor the program. Some of the tenant groups whose applications for permission to buy their homes under the trial program are still being considered by HUD "have not gained total cooperation from the housing authorities," she said.