The NHS recommends avoiding certain foods if you have a stomach ulcer, including spicy foods, acidic foods, and high-fat foods. It is also important to limit or avoid alcohol and caffeine, as these can irritate the stomach lining and worsen ulcer symptoms.