Both the expressions are used interchangeably.
However, “by” is used when the agent is temporary while “with” is used to denote a chronic agent.
For example, Mona skipped class today as she is afflicted by the flu.
(Flu is a temporary agent).
The beggar is afflicted with leprosy.
(Though leprosy is curable but the treatment takes a lot of time. Hence, it is a chronic agent).
Afflicted means ‘affect adversely with pain and illness’.
‘Afflicted with’ is used when the disease is stays for long period of time.
For example : He was afflicted with asthma, and his retirement was relieved only by the society of a few chosen friends.
‘Afflicted by’ is used when the disease or illness stays for a shorter period of time.
For example : Syria was afflicted by a serious famine.