Sayyiduna Jabir bin Abdullah (may Allah be pleased with both of them) reports: The Prophet (peace and blessings be upon him) said: "Whoever has eaten garlic or onion should keep away from us and our mosque." Or he said: "He should stay at home."
Related hadith on this topic