If it's in your face it's hard to keep it out of your mouth.
Best to use stuff that's non-toxic at least, even if it's not food. Like if you use paint use the stuff you can give to kids. Methylcellulose/natrosol etc are not "good" to eat, but are safe if you swallow a bit (they're used as food thickeners).
If it's not safe to accidentally swallow even a small amount of whatever it is - it's probably not safe to use at all.
There are still a lot of substances that are safe - or not harmful with limited exposure - that are still pretty unpleasant to get a taste of (or in eyes).
Have a glass of water and a few towels and flannels handy. It's never the most delicate thing but just spit it out if you have to and rinse your mouth out!
Stuff like this happens often. During shoots these generally get cut - you may or may not be aware of the long standing 'no-spitting' rule in UMD's T&C during commercial scenes!
Besr advice is to just try keep your mouth closed while whatever it is is being poured or splattered on to you. Something I tend to do during a pie session is, if I need to breathe through my mouth, I hold my hand up to signal I need to breathe so the person pieing me knows to stop for a minute and I'm less likely to get foam in my mouth. You can apply the same rule if there's gunge or something being poured on you