Coronary artery surgery, an often controversial and always costly operation that has virtually taken over many operating rooms, was given a hearty endorsement at the National Institutes of Health yesterday.

Though the explosive spread of this $10,000-to-$20,000 operation has alarmed critics of exploding health costs, a "consensus development panel" of 12 experts called the surgery "a major advance" in treatment after heart attacks. The panel said it extends life for many persons, and some members said it may improve the chance of continued life by two- or threefold in "appropriate patients," mainly those with disabling angina or chest pain. Some advocates said the advance is well worth the $1.6 billion a year that it may be adding to the national health bill.

If all the "appropriate patients" as defined by the panel are operated on in future years, it might add 25,000 or 30,000 annually to the 110,000 of these operations now taking place. The annual rate was 50,000 in 1975.

But many heart surgeons are already extending the operation to still more categories of patients. Some authorities think the operations may soon number 200,000 a year, at an annual cost of $3 billion, a hefty segment of the current $235 billion national health bill.

In most heart attacks, the "attack" really consists of a blockage of one of the coronary arteries that wrap themselves around the heart and feed it with freshly oxygenated blood. The lack of oxygen then kills or impairs a section of heart muscle.

In this new "coronary artery bypass surgery," to give it its full name, the surgeon takes one or more sections from the saphenous vein in the patient's leg, the same vessel often removed to treat "varicose veins."

The surgeon uses these to make one, two, three or more grafts to replace the old blocked vessels and supply the heart with fresh blood.

The arguments about such operations have mainly been three: Do they improve quality of life? Do they extend life? Which of the many heart patients might benefit?

After two full days of debate and a final set of arguments that lasted until 2 a.m. yesterday, NIH's panel of surgeons, medical specialists and statisticians agreed yesterday that:

The operation is mainly one for the patient with disabling angina caused by lack of enough oxygen in the heart cells. Such pain occurs mainly in patients with severly narrowed or damaged heart arteries, and the operation is justified even if it only relieves this frightening and disabling pain and does not extend life.

But if data "indicate" that the patient is [also] at high risk of sudden death or infarction [further heart attack] -- for example, the patient with severe stenosis [narrowing] of the main trunk of the left coronary artery or severe stenosis of multiple major coronary branches -- especially serious consideration" should be given to surgery. "If studies indicate . . . there is no critical stenosis of any major coronary branch, then clearly surgery is not indicated."

"A very large percentage of patients fall between these categories, and here the patient's doctors cannot avoid a "highly judgmental" decision based on each patient's situation.

At least half the patients, it was added, will get only temporary relief, though perhaps lasting some years. This is because they still have the basic condition -- advancing atherosclerosis or artery disease -- that cause their heart disease in the first place. In a group of patients who live 10 years after surgery, about 5 percent each year will suffer new narrowing of their grafted heart arteries or elsewhere in their original ones.

Persons who undergo the surgery are not, studies show, any more likely to go back to their jobs than heart attack patients treated with drugs. But they are often able to resume or start sports or other strenuous activity and, said one doctor, "enjoy life."