Is it wrong to keep in contact with a ex boyfriend just for sex?

If either of you are in a new relationship yes. If you have to ask the question, then I think you already know what the answer is.