To afflict means to cause pain or suffering. For example, you might be afflicted with foot-in-mouth disease. This means that you suffer from frequently saying the wrong thing at the wrong time.
Of course, foot-in-mouth disease is not a real disease. Yet a number of people seem to be afflicted with it.
By way of clarification, I should note the when you “stick your foot in your mouth” you don’t literally stick your foot in your mouth. That would take a great deal more flexibility than I have and literally sticking your foot in your mouth would be a major faux pas were you to do it in public.
Sticking your foot in your mouth simply means saying something in appropriate, usually unintentionally.
I don’t know how “stick your foot in your mouth” came to have its idiomatic meaning and I’m far too lazy to try to find out. Fortunately, this is an entry on the word afflict. I’m way, way, way off topic so there’s no reason why I should bother to look it up now.