From the book Anesthesia in Cosmetic Surgery, edited by Barry Friedberg (Publisher: Cambridge University Press):
Prior to the late 1800s, one could get drunk or literally bite the bullet, neither of which had any effect on pain. An interesting article appeared about a .50 caliber bullet found at the site of the Battle of Ox Hill. The 21st Massachusetts Regiment had fought at a local cornfield with extreme and horrifying injuries. Yet, they had no medical care. The bullet has molar tooth cusp imprints, reportedly from a patient biting during surgery without anesthesia.
An evidence possibly showing the origin of the phrase is the tooth marks found on a 200-year-old musket ball on display at The Dr. Samuel D. Harris National Museum of Dentistry:
The bullet on display at the museum was excavated from what is now the Northport section of Baltimore but is believed to have been a field hospital during the War of 1812. University of Maryland Dental School pathologist and forensic odontologist Dr. Bernard Levy analyzed the musket ball and verified the impressions are from a human’s dentition.
This makes the musket ball a rare find because while many lead musket balls from the Civil War and prior conflicts have been found with teeth marks on them, Dr. Swank said the vast majority have been chewed on by feral hogs who rooted them from the ground. Spotting the difference between a bullet chewed by a hog and one a human chomped on to withstand a painful medical procedure takes some skill, but dental professionals are best equipped to notice.
Here is another evidence, chewed bullets from the Battle of Antietam. These bullets, which Civil War soldiers bit during surgery conducted without anesthesia, are known as pain bullets also:
Archaeologists have determined that these human-chewed bullets are most likely from men who perhaps believed it would ease their pain to "bite the bullet."
On the other hand, I found some sources that are against the idea of pain bullets. They think that people wouldn't put easily swallowed bullets in their mouth during surgeries and bite marks on the bullets are mostly from animals and especially from hogs.
Here is a plausible explanation from an antique medical, surgical & dental artifacts resource site:
So-called medical chewed or pain bullets are mis-identified. An easily swallowed bullet is the last thing that one would want to put in the mouth of any anxious patient. To bite the bullet is not a medical phrase, rather it is an old military term referring to loading a muzzleloader. The tip of a preloaded ball and powder paper cartridge was opened with the soldier's teeth, the powder and ball were then poured into the muzzle, the paper cartridge, itself, came next as packing, lastly, all was tamped down with a ram rod. In the heat of battle, it is possible that soldiers may have bitten the paper cartridge at the wrong end (bullet end) and this may have caused some of the marks.
Ciwilwarscholars.com and civilwarvirtualmuseum.org are among the sources that are against the pain bullet idea. For example, in one of the sources, it is mentioned that both chloroform and ether were available for administration before surgery. The first method of anesthesia, nitrite oxide, was introduced in 1844; ether as an anesthetic was first used by Horace Wells (an American dentist) in 1846; and the Scottish obstetrician James Young Simpson first used the anesthetic qualities of chloroform in 1847. But there is an evidence that there are chewed bullets with human bite marks that are older than the discovery of anesthesia.
Although there are some plausible explanations against the theory, most authoritative sources favor it. So we can conclude that there is strong evidence from authoritative sources that pain bullets were used during surgeries; and it is the origin of the phrase "bite the bullet".