An upright or grand piano is basically a cabinet that houses the mechanisms that create music, and like any cabinet, it can develop a musty odor, especially if you keep it closed. A disagreeable odor is a sign it needs a cleaning, and you can do that yourself. You can also deodorize your piano, but you may need help if the inside needs a deep cleaning; only a professional should work around the moving parts.
Washing the Outside
White vinegar effectively kills the mildew that cause odors, and washing the outside of the piano with a light solution consisting of 1 part vinegar to 10 parts water is safe for the finish. Soak a cleaning rag in the solution and wring it out well before wiping down every square inch of the instrument, including the keys and casters. Allow the solution to dry, then wait for a day or two for the acetic acid odor of the vinegar to dissipate. If you can still smell musty odors from the piano, wash it again. It will also help to use some deodorizers.
Cleaning the Inside
Your piano may be the oldest piece of furniture you have, but unless it was seriously abused, the inside was probably kept dry, and the bulk of the mildew and dirt causing its musty odor is probably on the outside. In some cases, you may find a mouse nest or some other indication that critters were using the piano for shelter, and if so, you need to remove the debris and sanitize it. After removing as much as possible with a vacuum, you may find that the strings need washing. This isn't something you should do yourself -- not only can you throw off the tuning, the strings are under tension and can break. Contact a professional for such cleaning.
Deodorizing the Piano
If two treatments with vinegar don't solve the odor problem, you can use charcoal, baking soda or both to absorb odors that may be coming from inside the instrument. Place charcoal briquets in strategic places inside the cabinet, ensuring they won't interfere with the operation of the piano if someone decides to play it. Baking soda isn't solid like charcoal and must be placed in a porous container -- an old sock is ideal. Position several baking soda socks inside the cabinet, again verifying they won't move if someone plays the piano.
Moisture and Humidity Control
Humidity is the enemy of old wooden furniture pieces like pianos; it promotes the growth of mildew and the creation of odors. If you can't control the humidity in the room in which the piano is located, verify the room has plenty of ventilation. Keep a window slightly open and the door open to create a draft or place a fan in the room to keep air moving. If you have an upright piano, it should never be right up against the wall, because without ventilation between the piano and the wall, condensation collects and mold grows. Pull your piano out at least 6 inches from the wall to prevent this from happening.