When a pharmacy sells the heartburn drug Zantac, each pill costs about 35 cents. But doctors dispensing it to patients in their offices have charged nearly 10 times that price, or $3.25 a pill.

The same goes for a popular muscle relaxant known as Soma, insurers say. From a pharmacy, the per-pill price is 60 cents. Sold by a doctor, it can cost more than five times that, or $3.33.

At a time of soaring health care bills, experts say that doctors, middlemen and drug distributors are adding hundreds of millions of dollars annually to the costs borne by taxpayers, insurance companies and employers through the practice of physician dispensing.

Most common among physicians who treat injured workers, it is a twist on a typical doctor’s visit. Instead of sending patients to drugstores to get prescriptions filled, doctors dispense the drugs in their offices to patients, with the bills going to insurers. Doctors can make tens of thousands of dollars a year operating their own in-office pharmacies. The practice has become so profitable that private equity firms are buying stakes in the businesses, and political lobbying over the issue is fierce.