(Aside about whether Tom Bombadil could have protected the Hobbits from the black riders more actively as they slept in his cottage:)
(That he could do that is hinted in the flight to the Ford when Frodo tries to tell the black riders to stop and go back to Mordor - but it says, "The Riders halted - but Frodo had not the power of Tom Bombadil". That would seem to suggest some previous episode known to the narrator when Tom stopped them - also Frodo's dream about the black riders and his reaction when he wakes up in Tom Bombadil's house: "There was a noise like a strong wind blowing, and on it was borne the sound of hoofs, galloping, galloping, galloping from the East. ‘Black Riders!’ thought Frodo as he wakened, with the sound of the hoofs still echoing in his mind. He wondered if he would ever again have the courage to leave the safety of these stone walls. He lay motionless, still listening; but all was now silent, and at last he turned and fell asleep again or wandered into some other unremembered dream." - hints at the possibility there with "all was now silent" that his dream might have been triggered by actual hoofs galloping outside of Tom Bombadil's cottage - then after they wake up, reinforcing this hint: ... "He had half expected to see turf right up to the walls, turf all pocked with hoof-prints".
But beyond that - in the book as it is there is no account of Tom stopping them. I'm not sure, but I have a vague memory that perhaps this was made more explicit in an earlier draft, the suggestion that Tom Bombadil somehow held the black riders off while they visited him. Is that true or was it never made any more explicit than this? If anyone knows more about this, do say in the comments).