when does Odysseus reveal his identity? how has he been careful in keeping that information to himself from Books 5-8?

Odysseus's men knew who he was, but then eventually, he lost all his ships and all his men over a period of time through many dangerous adventures.

If you're referring to when he revealed his identity once he got back home, look at books 23 and 24.
http://www.sparknotes.com/lit/odyssey/

In the epic poem "The Odyssey" by Homer, Odysseus reveals his identity to various characters at different points in the story. Specifically, Odysseus reveals his identity to his son, Telemachus, in Book 16, to the swineherd Eumaeus in Book 17, and to his wife, Penelope, in Book 23.

From Books 5-8, Odysseus carefully conceals his identity and assumes the guise of a beggar named "Aethon." He does this to gather information, assess the loyalty of his household members, and plan his revenge against the suitors who have taken over his home in Ithaca.

To understand how Odysseus maintains his secrecy, we can look at some specific examples. Firstly, when Odysseus arrives on the island of Phaeacia in Book 6, he conceals his identity from the princess, Nausicaa. He approaches her respectfully and asks for her assistance, without revealing his true identity. This shows Odysseus' tactfulness in not rushing to disclose who he really is.

In Book 7, when Odysseus is entertained in the palace of King Alcinous, he listens to the songs recounting the Trojan War without arousing any suspicion. Although the stories remind him of his own experiences during the war, Odysseus remains composed and maintains his disguise.

Furthermore, in Book 8, when Odysseus recounts his adventures to the Phaeacians, he conceals his true identity by using a pseudonym. He calls himself "Aethon" and fabricates a story about being a merchant who suffered significant misfortunes. By doing so, he keeps his true identity hidden, even as he tells his audience about his journey home from the Trojan War.

Overall, Odysseus demonstrates great caution and cunning in concealing his identity throughout Books 5-8. He understands the importance of strategic planning and chooses not to reveal his true self until the opportune moments to achieve his goals.