The wai is traditionally observed upon entering formally a house. After the visit is over, the visitor asks for permission to leave and repeats the salutation made upon entering.
The wai is also performed when you are introduced to someone you meet at first time and you want to show respect to this person.
Usually, if the person being introduced is younger than you, your wai will be reciprocated to his/her wai, unless that person is of high respect to you.
The wai is also common as a way to express highly gratitude or to sincerely apologize.