From the Super Mario Wiki
The Frying Pan is a special item found in Paper Mario.
When Mario and his partners free the third Star Spirit, Skolar, they go back to Toad Town, as usual. He is surprised that the Shy Guys started to appear from Shy Guy's Toy Box and attempted to steal items from Toads and do pranks all over the town. When Mario goes near Tayce T.'s house, one of the Shy Guys steals her Frying Pan and hides it in Shy Guy's Toy Box. Since the Frying Pan is stolen, Tayce T. can't cook recipes for Mario for the time being.
The item is located in Shy Guy's Toy Box at the Pink Station. To access it, Mario has to get the Storeroom Key in the Blue Station that is guarded by a enemy or an item cast by Kammy Koopa. When he obtains it from the Treasure Chest, Mario must return it to Harry T. so he can let Mario access to his storeroom. The storeroom contains the important item, the Toy Train. When Mario goes near to the Toy Box, he puts the Toy Train in the box as he has access to the Pink Station. When Mario is at the Pink Station, he eventually notices an enemy or an item "guarding" the Treasure Chest that contains the Frying Pan.