This is funny, but I definitely see why you asked the question.
It really depends on context. Generally the phrase is sexual if if includes a specific person. For example, Johnny was messing around with Suzie at the party last night. However this isn't always the case.
"They messed around after everyone left"
The sexual connotation usually implies that they were messing around (with each other)
Messing around can be interpreted as bad behavior in other contexts.
"Stop messing around with me"
Dude, I'm just messing around with you, don't be so serious.
They were messing around with the dogs, when they should have been doing their homework.