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 forces everyone to dance to "Do the Koopa", Mario takes out his Plumber's Putty and sticks some in his ears. This way, he cannot hear the Doom Dancer Music Box, and is free from its spell. He "dances" over to Bowser until he gets the chance to try and grab it. Eventually, Luigi and the Koopalings get involved, but ultimately shatter the Doom Dancer.