I would like to know if this expression's an offense
Wo hast du dich herumgetrieben?
Is it used to scold somebody?
The verb "herumtreiben" or the corresponding word "Herumtreiber" primarily means "act as a vagabond", being homeless or even an outlaw.
If you ask someone:
Then you imply that whatever he did or where he was, it is beyond debate that it was something immodest. As long as you don't say it to a friend of yours, it is very disrespectful. It would be used for someone dishonest or roguish.
If used talking to an adult it can be considered as (strong) insult. One example where someone adult could say this to another adult was if your boss was angry with you and wants to clearly show his anger and / or to humiliate you.
I also know this phrase, either as scolding (as mentioned in Jbartmann's answer) or alternatively as a greeting or "How have you been lately?"-ish conversation starter. I prefer to use it only when the conversation partners didn't see each other for a relatively long time.
In both cases, it is more jokingly said.
It's colloquial and implies that the person being asked is coming (home) late or dirty or drunk. Since it's only used in family context (parents asking children, maybe partner asking partner) I'd not consider it offensive.