First, make sure you have a proper P-trap installed under the sink. This trap holds water and provides a seal against sewer gases getting up into the bathroom. Without a P-trap, gases will leak in constantly, and will be displaced by water down the drain which can force the gases up into the bathroom even if normally it’s not detectable.
Also make sure there is a proper vent for the sink. Even with a P-trap, if there’s nowhere for back-flowing gases to go, they’ll bubble up past the trap. (And even if you don’t have a vent, that might be OK.)
One more thing it could be is the overflow drain. Depending on the design of sink, the overflow can hold a small amount of water at the bottom where it T’s in to the main drain, which can become stagnant. Run water down the drain and you’ll force some air up the overflow (to make way for the water coming down), which will have that stagnant smell.
To diagnose this, plug the sink and begin filling it; you shouldn’t get any musty smell at first because there’s no air movement. Once the water level hits the overflow drain, you will start smelling the musty smell for a while because the water is displacing the gas, which wants to rise above the water and so will move up into the bathroom. If this is the problem, you can ameliorate it with some foaming pipe snake; pour it down the overflow drain and it will clean out any caked-on gunk which contributes to the smell, and which may be trapping the water. The real fix is to make sure there’s no “damming” effect of construction defects at the bottom of the overflow drain (a lip of porcelain, issues where the overflow meets the metal drain downpipe, etc).
Does it smell when you turn on the tap and catch the water in a bowl (so it doesn’t go down the drain)?
If so, it’s something in the faucet. Take off the aerator cap and look for gunk inside. Also, look in the barrel of the faucet and clean it out if you can. And of course you can also consider replacing the faucet.
If this doesn’t work, it’s something in the basin, drain, trap, or overflow drain. KeithS has some good answers above, but I also recommend the following:
– Take out the drain stopper and look down the drain pipe for gunk. Clean it out with a snake or unraveled coat hanger if you can.
– Spray bleach down the drain and overflow drain to kill anything nasty in there. You can bleach the basin too for cleanliness.
– Get a large bowl or 1-5 gallon bucket. Fill it with water. Quickly but carefully pour all the water down the drain. The goal is to fill the basin and displace all/any water in the overflow drain and trap. Sometimes there can be nasty things in there that float so they don’t go through the trap, and this forces them out the drain pipe.