For pain relief when you have heartburn or indigestion, paracetamol is usually the gentler choice on the stomach and does not typically clash with antacids or acid-reducing medicines. Anti-inflammatory painkillers (NSAIDs) such as ibuprofen, naproxen and aspirin can increase stomach acid irritation and raise the risk of ulcers and bleeding, so they are best avoided or used with care if you have reflux or ulcer problems.
Doses, timing and suitability depend on your other medicines and health conditions, so this is informational rather than a personal recommendation. A pharmacist can check for interactions, for example with blood thinners, and advise the safest option for you.
Seek urgent care or call your local emergency number if you develop severe stomach pain, vomit blood, or pass black tarry stools while taking anti-inflammatory painkillers, as these can be signs of a serious stomach bleed.