Both afflict and inflict cause pain, but afflict means to cause suffering or unhappiness, something a disease does, but inflict means to force pain or suffering, like if you smack someone upside the head.
If something afflicts you, it hurts. Cancer, death, arthritis, or even bad skin can afflict you. Afflict is often, but not always, followed by the preposition with:
It's also quite likely that he was afflicted with an eating disorder. (Slate)
He has never publicly revealed what type of cancer afflicted him. (New York Times)
In the proud tradition of genuine watchdog journalism, Khalil Bendib's work aims to comfort the afflicted and afflict the comfortable. (Brunei Times)
Inflict is meaner. It's more aggressive — it actively hurts and causes problems. A self-inflicted wound is when you hurt yourself. Inflict is often, but not always, followed by on:
Some participants in the debate said the rule could unintentionally inflict economic harm on Africans. (Washington Post)
Five other men accused of taking part in the fight were convicted of hooliganism and inflicting light bodily injury. (Seattle Times)
Most injuries are self-inflicted; they're not necessarily inflicted by others. (New York Times)
The difference between the two is whether the emphasis is on the one suffering or the one causing the suffering. Afflict emphasizes who is doing the suffering. Inflict emphasizes the person or thing causing the suffering. Try this: I am afflicted with something terrible, so I inflict injuries upon others.