If a guest stays overnight in his host’s home, he is considered part of the household and therefore fulfills his mitzvah through the host’s lighting. He must ask the host to have him in mind when he lights. Some guests give the host a few coins to purchase a share in the oil and wicks, although it is not necessary to do so.
If you attend a meal at your host’s home you can still fulfill the mitzvah through your host’s lighting of the candles. This is the ruling of Rabbi Yaakov Kaminetsky (a”h), as he wrote in his sefer Emet L’Yaakov. This is also the ruling of Rav Shelomo Zalman Auerbach (a”h).
Ha’Rav Ovadyah Yosef (a”h), however, cites the ruling of the Mahari Katz (a contemporary of the Rama, in Poland) saying that the mitzvah of lighting depends upon where a person sleeps. Therefore, he rules that even though a person is in his parent’s home at the time the parents light, and the parents have him in mind, he must nevertheless light the Chanukah candles when he returns home.