The answer exactly mirrors the answer to "at what age should I stop bringing my opposite-sex child into Japanese hot springs?", which is to say "when it starts making them uncomfortable."
Seriously, there's no "right" age. Stop overthinking it. Do it until it doesn't work for the child, and they let you know. If you do it too soon, you may turn sexuality into a traumatic/bad thing unwittingly, as they link the opposite sex to a bad memory of switching bedrooms, etc.
Just like education, linking certain skills/expectations to age alone is a terrible mistake. Whenever you get the chance, appreciate and treasure the opportunity to treat your child as an individual, and allow them to grow at learn at their own pace.
At what age should a child no longer share a room with someone of the opposite sex?