In Harry Potter and the Deathly Hallows, Snape somehow knows where to find Harry, and by knowing so, places the Sword of Gryffindor for Harry to find. How does he find him?
Harry asked Hermione where they were after they disapparate. Hermione was poking in her beaded bag for the tent and Phineas Nigellus's portait heard her mention it.
It's revealed on page 386(of e-book version) when Harry looked into Snape's memories in the Pensieve.
From the book:
"And now Snape stood again in the headmaster’s study as Phineas Nigellus came hurrying into his portrait.
“Headmaster! They are camping in the Forest of Dean! The Mudblood – ”
“Do not use that word!”
“ – the Granger girl, then, mentioned the place as she opened her bag and I heard her!”
“Good. Very good!” cried the portrait of Dumbledore behind the headmaster’s chair.
“Now, Severus, the sword!”