Sexy time!

Is it okay to have sex with someone you’re not dating? I’ve had this belief only having sex while I’m in a relationship with someone, but my ex broke up with me a few months ago and I’ve been downright horny and I cannot satisfy myself.