If you have eaten garlic or onion, or carry a bad odour, keep away from the masjid until it goes. The Prophet ﷺ said: “Whoever eats from this plant (garlic) should not come near our masjid, for the angels are harmed by what harms people.” (al-Bukhārī & Muslim).
العربية: عن جابر رضي الله عنهما أنّ النبيّ ﷺ قال: «مَن أكل من هذه الشجرة — يعني الثوم — فلا يقربنّ مساجدنا، فإنّ الملائكة تتأذّى ممّا يتأذّى منه بنو آدم». (البخاري ومسلم).
Before the masjid, avoid strong odours (garlic, onion, smoke) and freshen up — out of respect for Allah's house and the worshippers.