FWIW OP, my DS has done/said similar and has ASD. The problem for him was he'd repeat thing said to him in the playground but because he has poor social skills, lacked the filter the other kids had that meant they knew nor to bring it into class, so unfortunately he whispered stuff in class and was immediately told on. I've supported the school in their punishments, but also made it quite clear where he had learnt these things and who from (and it's always the same names).
He is year 5 now and got himself in so much trouble with this at the end of last term he has really behaved himself so far this term. I think emotional maturity and social skills comes into it. A lot.
Thinking back to my own school days, it wasn't so different. I remember these conversations whispered behind the wall/bushes about who was going to 'do sex' with who, singing dirty songs that made no sense, learning at DS age what wankers, prostitutes, rent boys, gays and lesbians were etc. But we all knew to keep it to the playground, or where adults couldn't hear us. I comfort myself by knowing that they're all at it, but the other kids are way more savvy than DS and DS now knows the best approach is just to not say anything. I've told him he can laugh if something is said in a group, but not to repeat anything or add to the discussion.
Support them in the sanction, but ask them to put a time frame on it. Then speak with him and explain you are supporting school because if he did do this he has been very, very inappropriate, making it clear you will not tolerate this. If you find out later that he has lied to you (as DS did with me) to try and cover himself, then you will need to take appropriate action for the lies. I punish strongly for lying and I think that, in combination with school's punishment is what has improved DS behaviour in the past 6 months. When there was irrefutable evidence (he caught himself out) he suddenly had no one on his side and it was only then that he got the message.