An over–the–counter antacid is often used to relieve mild cases of heartburn or acid reflux. Though they are available without a doctor’s prescription they should be taken only under a doctor’s advice.

As per American Academy of Family Physicians

There are different types of antacids that work in different ways.
One should talk to the doctor before taking an antacid.
To manage an ulcer, an antacid may need to be taken in conjunction with an antibiotic.
If one needs more calcium to help strengthen bones, one should prefer an antacid that contains calcium carbonate.
In some, antacids may have minor side effects such as nausea, headache, diarrhea or constipation.
One should read the label carefully to make sure that one is not allergic to any of the ingredients.
People with kidney disease may not be able to take all types of antacids.
An antacid may interact with other medications.