Harry gave the Felix Felicis to Ron to split between Ron, Hermione, and Ginny, prior to leaving for the cave with Dumbledore to get the locket Horcrux. He was aware, because of meeting up with Trelawney after she was kicked out of the Room of Hidden Things by Draco Malfoy, that Malfoy had succeeded at whatever task he had been working at all year, and that something bad was going to happen (i.e. the Death Eaters got into Hogwarts) and he wanted R, Hr, and G to have extra protection, as well as to be able to have the special protection of the Felix Felicic potion to keep them safe. Subsequently, there was the small battle at the bottom of the stairs to the Astronomy Tower, where R, Hr, and G remained safe.
‘I haven’t got time to argue,’ said Harry curtly. ‘Take this as well –’ He thrust the socks into Ron’s hands.
‘Thanks,’ said Ron. ‘Er – why do I need socks?’
‘You need what’s wrapped in them, it’s the Felix Felicis. Share it between yourselves and Ginny too. Say goodbye to her from me. I’d better go, Dumbledore’s waiting –’
‘No!’ said Hermione, as Ron unwrapped the tiny little bottle of golden potion, looking awestruck. ‘We don’t want it, you take it, who knows what you’re going to be facing?’
‘I’ll be fine, I’ll be with Dumbledore,’ said Harry. ‘I want to know you lot are OK ... don’t look like that, Hermione, I’ll see you later ...’
Half-Blood Prince - Page 516 - British Hardcover