It’s true. It’s sod’s law, and it happens to all of us.
Except it isn’t just sod’s law. The fact that it happens EVERY DAMN TIME is proof in itself that there are greater forces at work here.
Yoghurt is made from milk, heated, curdled and set. For standard mass production this is done in large metal containers which conduct heat easily but are also simple to keep clean and hygienic. It is then usually packed up into plastic tubs and sent to your local supermarket for you to buy. We know that plastic is an insulator and helps keep the yoghurts cool and fresh, but it also happens that plastic is an electrical insulator too.
During manufacture, yoghurt loses electrons to the metal cooking vessels and is transferred into these insulated tubs in an unstable, positively charged state. It is a static zap waiting to happen, but with more mess! When you open the pot away from you, there is no charged object nearby to generate movement in the positively charged yoghurt particles. So there is no static splurge. But when your jumper, t-shirt, or even your face is nearby, the connection between electrons is made and in rebalancing the charge, your clothes are forfeit.
If you open your pots on a flat, earthed surface you will find it happens far less frequently.