When Imam Mahdis AJ name is mentioned, why do we put our hands on our heads?

Also, I understand that Allah SWT does not leave humanity without an Imam to guide us, but how can we be guided by the Imam of our time AJ while he is in occultation and cannot contact us or we cannot contact him?

Some say its because its a form of pledging allegiance, some say its a form of respect to say he is above our heads, some say its because the Imam will touch the heads of his followers perfecting their intellect. Allah knows best.

As for your second question, please read the following book

https://www.al-islam.org/fazail-ul-mahdi-ali-akbar-talaafi/benefits-imam-mahdi-aj-during-his-ghaibat