In Planet of the Dead, Carmen, a passenger on the bus, who has shown some physic ability, tells the Doctor to take care of himself. When the Doctor tells her this back, she replies:
No, but you be careful, because your song is ending, sir!
The Doctor asks what this means, and she replies:
It is returning. It is returning through the dark, and then Doctor...oh but then... he will knock four times.
In the next episode, The Water of Mars, the Doctor brings up the knocks again:
DOCTOR: No, 'cos someone told me just recently, they said I was going to die. They said "he will knock four times". And I think I know what that means, and it doesn’t mean right here, right now, ‘cos I don’t hear anyone knocking, do you?
(We hear three knocks)
DOCTOR: Three knocks is all you're getting!
(The Doctor electrocutes the knocker before he can knock a fourth time)
In the next episode, "The End of Time", it is revealed that
Gallifrey is the "it", Wilfred Mott is the "he", and the end of the song is the end of the tenth Doctor's incarnation.
The fate of the Master is addressed in another question.