In the USA, I imagine Germany too, only way it would be "illegal" is if you were contractually obligated to not be reckless or engage in reckless activities. I imagine this is for top officials such as CEOs or maybe a sports star, not common workers. Even with that clause, they typically mean something like engaging in parachuting or something with a known danger, not eating spicy food.
With that said, you may be asked to bring in a doctor's note. That wouldn't be unfair for your employer to request such thing. In the future, avoid food you know will cause illness. Not so much for work reasons but for health reasons.
I eat pizzas on a regular basis but last time I went with co-workers, we ate at this pizza shop and the spinach on mine must have been rotten or something because I got really sick afterwards. I went home and came back to work the next day. No questions or issues since that's what sick leave is for. I do not go to that pizza place any longer, though, but next time I would be more careful about what toppings I choose at the establishment.