There will probably be enough heating oil to warm the country this winter, but it will cost 50 percent more than last year, partly because oil companies have increased their profits from the fuel, a senior Energy Department official said yesterday.

Oil industry spokesmen acknowledged that they have increased profit margins at the refinery somewhat, but defended that action on grounds that profit margins had long been inadequate, and the higher levels would lead to refinery modernization and expansion.

In testimony before a joint hearing by two House energy subcommittees, outgoing Deputy Energy Secretary John F. O'Leary said many people may face "a cruel choice between food or heat" this winter because of the sharp rise in heating oil prices since last year.

O'Leary released new DOE figures showing that the average price of heating oil to the consumer has risen from 53.7 cents per gallon in January 1979 to over 80 cents per gallon today.And, he said, further increases are likely throughout the winter.

One of the largest elements of the increase so far, beyond the obvious leap in crude oil costs, came in refiner margins, O'Leary said. His figures indicated that refiners were taking in from retailers and resellers 50 percent more in June than they were in January for the same amount of heating oil.

At the same time, he said, those same resellers and retailers were increasing their margins only by about 7 percent.

O'Leary said that some of his figures might be off a little because of "statistical weaknesses" but that in general they are correct. And he went on to say that if the refiner margin increases were running up as fast as it appears, "There is cause for major concern," requiring further investigation on the part of the Energy Department.

When O'Leary speaks of the refiner's margin, he refers to the price at which the refined heating oil is sold to resellers and retailers minus the cost of the crude oil used to make that heating oil. In January, the price from the refinery was 41.9 cents per gallon, with crude oil costs to the refiner about 31.2 cents per gallon. That meant the refinery margin was 10.7 cents per gallon.

But by June, O'Leary said, the price from the refinery jumped to 56.4 cents, an increase of 14.5 cents per gallon. At the same time, crude oil costs increased only about 9.3 cents per gallon. That meant, O'Leary said, that the refiner margin jumped 5.2 cents per gallon to 15.9 cents during that six-month period.

Much of that 5.2-cent increase was due to increased costs, according to Charles Bowman, vice president of Gulf Oil Refining and Marketing Co., who also testified.

"Our labor costs increased as of January, and the cost of fuel used in operations also went up considerably," Bowman said in an interview following his testimony. "But there is without question an element of increased profits. Our profits on heating oil have definitely improved. We don't take issue with O'Leary's numbers."

Bowman said "our profits on distillates [which include heating oil] have basically been unsatisfactory since 1973, to the point where we have not been encouraged to make new refining investments to meet growing demand."

By contrast, he added, the new increases in profits -- "the first real increase in profit margins in this industry since 1973 when heating oil was first put under price controls" -- have led Gulf to "commit $250 million to a major refining modernization and expansion program."

Spokesmen for two other major oil companies said they concurred with Bowman's analysis.

Heating oil is used in more than 16 million homes across the country, about 23 percent of all residences. That is down from 26 percent in 1970, according to a consultant's report prepared for the DOE.

The same study showed that only about 9 percent of all new houses being built use heating oil.

Most of the nation's heating oil users are in the Northeast region; where 60 or 70 percent of all homes use the fuel. That number drops to as low as 3 percent in many Western and Southwestern states.