Sayyiduna Abu Hurayrah (may Allah be pleased with him) narrates that the Prophet (peace and blessings be upon him) said: "When you enter your house, pray two rak'ahs; these two will keep you from entering into evil. And when you are about to leave your house, pray two rak'ahs; these two will keep you from going out into evil."
Al-Bazzar recorded it, and its narrators have been declared trustworthy.