In Harry Potter and Deathly Hallows part II, Harry comes to realize that the Lost Diadem of Rowena Ravenclaw is in Hogwarts school of witchcraft and wizardry and that later Harry finds it in the room of requirement. Can anybody point me out how and when Voldemort hid the Diadem (Horcrux) in the school as he must have to visit the school in order to hide it?
He hid it there when he came to ask for the position of Defense Against the Dark Arts.
This is made clear in the books:
So Voldemort had managed to wheedle the location of the lost diadem out of the Gray Lady. He had traveled to that far-flung forest and retrieved the diadem from its hiding place, perhaps as soon as he left Hogwarts, before he even started work at Borgin and Burkes.
And wouldn’t those secluded Albanian woods have seemed an excellent refuge when, so much later, Voldemort had needed a place to lie low, undisturbed, for ten long years?
But the diadem, once it became his precious Horcrux, had not been left in that lowly tree.... No, the diadem had been returned secretly to its true home, and Voldemort must have put it there —
“— the night he asked for a job!” said Harry, finishing his thought.
“I beg your pardon?”
“He hid the diadem in the castle, the night he asked Dumbledore to let him teach!” said Harry.
Saying it out loud enabled him to make sense of it all. “He must’ve hidden the diadem on his way up to, or down from, Dumbledore’s office! But it was still worth trying to get the job — then he might’ve got the chance to nick Gryffindor’s sword as well — thank you, thanks!”
Harry Potter and the Deathly Hallows, chapter 31: "The Battle of Hogwarts" (emphasis added)