From the Super Mario Wiki
Plumber's Putty is a tubed substance that appears in The Adventures of Super Mario Bros. 3.
The Putty only appeared in "Do the Koopa". When Bowser forced everyone to dance to "Do the Koopa", Mario took out his Plumber's Putty and stuck some in his ears. This way, he couldn't hear the Doom Dancer Music Box, and was free from its spell. He "danced" over to Bowser until he got the chance to try and grab it. Eventually, Luigi and the Koopalings got involved, but ultimately shattered the Doom Dancer.