Mold grows wherever there is a moisture source combined with darkness, and this makes basements particularly susceptible. If the basement started smelling after a leak, the water from the leak is responsible, and the source needs to be identified and repaired before any further action is taken. Otherwise, more water will continue to seep in, and any other efforts to remove the smell will be for naught. Look for cracks in the walls and ceiling, along with any collecting pools of moisture. Severe leaks likely will require professional repair.
Once the source of the leak has been eliminated, focus on any mold or mildew that is causing the musty odor. Wear a dust mask to prevent the inhalation of mold spores, because they can cause breathing difficulty. Commercial mold removers often utilize a bleach solution to kill and remove the mildew. Wear rubber gloves whenever you use bleach-based cleaners, because they are corrosive to the skin. White vinegar is also a useful mold killer, because it is mildly acidic but nontoxic and not as corrosive as bleach. Scrub at mold with a scrub brush when using the cleaner, to ensure that spores are removed from crevices and pores in the floor, walls and ceiling.
Open windows and doors in the basement, and bring in fans to increase the speed of air flow in the room. Circulating the air helps eliminate both the smell of any cleaners you used on the mold and the mold itself. Basements often smell musty anyway, because of poor air circulation, and water leaks only contribute to this problem. Leave the windows open and the fans running overnight, and much of the odor should be gone in the morning.
There are multiple natural deodorizers that also assist with the removal of musty odors. White vinegar not only kills mold, it also helps eliminate its odor. Spray a white vinegar-and-water solution around the basement. Focus on the areas where the leak was located. The vinegar scent will disappear by itself within a few minutes. Another option is to boil white vinegar in a pot and then place it in the basement for the steam to absorb existing smells. Sprinkle baking soda over any previously moldy areas as well, and vacuum it up after several hours for additional odor control.