Smelling soil should be a pleasant experience; fresh soil gives off an earthy, but not dirty, scent. If the soil of your houseplants or outdoor plants has a rotten odor, including traces of sulfur or ammonia, then the most likely cause is that too much water gathers in the soil.
Understanding the Smelly Truth
Soil that holds too much water has an odor because of the bacteria that thrive in wet conditions. Healthy soil includes air pockets, which help plant roots "breathe." When the air pockets fill with water, the environment goes from aerobic, or oxygenated, to anaerobic, or lacking oxygen. Normal soil has healthy bacteria, but anaerobic soil harbors a different type of bacteria, which emit an odor that marks their unhealthiness for plants.
In many cases, changing your plant-watering habits helps combat the problem of excess water in the soil. Whether the plants are indoors or outdoors, water them only when the top 1 inch of soil feels dry to your touch. Most indoor plants need water only once or twice each week. Outdoor plants need more water more in hot, sunny weather and less in colder seasons. Rain may be enough to keep outdoor plants properly watered.
Determining Soil Types
Dampening outdoor soil then squeezing it in your hand will help you determine whether the soil is dense or loose. If it falls apart, then it probably contains a good bit of sand, which means it typically drains well. If it forms a hard ball that doesn't lose its shape when you let go of it, then the soil may be dense, containing materials, such as clay, that don't drain well.
Amending the Soil
In the case of sandy soil, drainage isn't usually the problem; overwatering is most likely the culprit when sandy soil has a bad aroma. In the case of dense soil, though, adding amendments helps the soil drain and have a better aroma. Adding the amendments throughout a flowerbed ensures proper drainage, but adding them in just one section, such as where you plan to add a plant, won't help solve a smelly drainage problem. Mix a 2- to 4-inch-thick layer of compost or another organic material, such as aged manure, into the top 8 inches of soil using a tiller or shovel.
Repotting indoor plants in new, well-draining potting soil can help keep a soil odor from returning. Look for potting soil containing amendments such as perlite or vermiculite, both of which help with drainage.