I think you gave him too much punishment
You are definitely right when you say that this behavior can't go on, and that you should sit down and talk to him about it. He is merely six years old, so a week long punishment means nothing by day 3. He completely forgets why he is in trouble and it becomes routine. At a young age such as his, routine happens quickly. His typical bedtime is 8 o'clock, after changing this and making it 'routine', the fourth night, he is accustomed to it, and it is not difficult or anything different.
So, ultimately, you need to talk to him about it, explain why it is not nice, it is not appropriate, and explain to him that the little girl is different, she has different ' no-no spots' and that she doesn't like it when little boys try to touch those and change it up a bit, and explain to him that if he is doing something she doesn't like she isn't going to want to be his friend and will not want to play with him anymore. Kids don't like the idea of losing friends!
Good luck to you! And Btw, Welcome to the community!