No, you cannot use these interchangeably.
Assume that you are married, and have a child then
I'm not having an affair with anyone means a love affair
I'm not having a relationship with anyone, is not true, because you have a relationship with your wife and a relationship with your child.
affair usually means love affair
relationship does not always or usually mean a love affair.