THe House Ways and Means Committee voted yesterday to allow homeowners who sell their houses a once-a-lifetime chance to escape payment of taxes on the first $100,000 in profits from the sale, even if they don't use the money to buy a new home.

The measure was approved on a 22-15 vote as part of a liberal-backed plan to try to head off a cut in general capital gains taxes that the panel is considering. Capital gains are the profits from the sale of stocks or other property.

The measure would cost the government an estimated $785 million a year. The Treasury said it opposed the change.

The action came as the committee moved toward completion of a major tax cut bill that is expected to differ sharply from one proposed in January by President Carter. The president has said he may veto the Ways and Means version.

The homeowner's provision would replace an existing law that allows taxpayers over 65 who sell their homes on retirement to exclude for tax purposes the first $35,000 of the selling price.

Yesterday's measure would apply to taxpayers in all age brackets. It would require the seller to chose between the new $100,000 exclusion and the present option of "rolling over" a profit from his house sale by using the money to buy a more costly home within 18 months.

As under present law, a taxpayer would be able to escape payment of taxes on the profits from the sale of his home as many times as he qualified by reinvesting the money in a new house. However, he would be able to claim the $100,000 exclusion only once during his lifetime.

The legislation is intended to deal with complaints by older persons that capital gains taxes are sapping the profits from selling their homes upon retirement - a windfall that for many is their only chance of amassing a large sum.

However, if a taxpayer elected to claim the exclusion earlier in his career - say, to avert high taxes when he sells his home to transfer to a lowercost area - he could not claim it again when he reached retirement age.

Approval of the measure came as the panel continued work on a compromise substitute for President Carter's tax cut plan, rejecting several attempts by liberals to load the bill with amendments in an effort to doom it when it reaches the House floor. The liberals hoped inclusion of the homeowners' provision might dampen support for a broader capital gains cut.

In one victory for the administration, the panel rejected a proposal by Reps. Barber B. Conable (R-N.Y.) and Joseph L. Fisher (D-Va.) that would have allowed taxpayers who do not itemize to claim deductions on their short forms for contributions to charities. This measure, which was pushed vigorously by charities and foundations, would have cost the Treasury between $1.7 billion and $3.6 billion.

A bill the committee is considering would cut capital gains taxes by exempting capital gains from the present 15 percent additional "minimum tax" enacted in 1969 to prevent abuse of tax shelters. Under the present law, half of a capital gain is subject to the minimum tax.

The proposal, drafted by Rep. James R. Jones (D-Okla.), would effectively cut the maximum rate for capital gains to 35 percent, down from the 49.1 percent now paid by a handful of high-income taxpayers. A rival Republican plan, by Rep. William A. Steiger (Wis.), would slash this to 25 percent.

Besides the cut in capital gains taxes the Jones bill also would provide $15.2 billion in tax cuts for individuals and business.

The panel has been working on the tax bill since early January. The Jones measure is supported by a coalition of Republicans and concervative Democrats but the president has threatened to veto it.

The exclusion affecting home sales would provide homeowners with something of a hedge against the impact of inflation on house prices. Here is how it would work:

Say a taxpayer claimed the exclusion for a home sale in which the profit was $150,000. The first $100,000 of that would be tax free. Of the remaining $50,000 only half would be subject to tax, at the rate the taxpayer pays in his income bracket.

To qualify for the exclusion, a taxpayer would have to live in the home for at least two years before selling it - a rule designed to deny the benefit to speculators. It was not immediately clear when the measure would go into effect, but staffers thought it was likely to be made retroactive to yesterday. The measure was sponsored by Rep. Sam Gibbons (D-Fla.).