How should I prevent peptic ulcers?

Avoid NSAIDs. The 2 most common causes of stomach or duodenal ulcers are infection with the helicobacter pylori bacteria and the use of non-steroidal anti-inflammatory (NSAID) drugs such as aspirin, ibuprofen, naproxen, meloxicam, etc.
Minimize risk factor. Avoid smoking, alcohol, caffeine. Decrease your stress. Also, foods that can increase acidity of your stomach can increase reflux and pain, these include spicy or acidic foods like salsa and orange juice among other foods. For more specific information for you discuss with your doctor.