You may reduce your risk of peptic ulcer if you:
Protect yourself from infections. It's not clear just how H. pylori spreads, but there's some evidence that it could be transmitted from person to person or through food and water.
You can take steps to protect yourself from infections, such as H. pylori, by frequently washing your hands with soap and water and by eating foods that have been cooked completely.
Use caution with pain relievers. If you regularly use pain relievers that increase your risk of peptic ulcer, take steps to reduce your risk of stomach problems. For instance, take your medication with meals.
Work with your doctor to find the lowest dose possible that still gives you pain relief. Avoid drinking alcohol when taking your medication, since the two can combine to increase your risk of stomach upset.