From the Super Mario Wiki
The Whale can be found in the Toad Town docks after Mario rescues the Star Spirit Muskular from Shy Guy's Toy Box. When Mario arrives in the area, the Whale is partially submerged underwater, and Mario must either Ground Pound the Whale's back or hit it with a hammer three times to rouse it. Upon surfacing, the Whale starts complaining about a bellyache, and asks Mario to go inside its stomach and find the cause. Upon doing so, Mario finds Fuzzipede jumping around in the Whale's belly, and engages it in combat.
After Mario defeats Fuzzipede, the Whale feels better and ejects them via its blowhole. In return for the assistance, the Whale transports Mario back and forth from Toad Town to Lavalava Island when needed. The Whale was also responsible for bringing the Yoshi chieftain alongside another Yoshi to Toad Town from Lavalava Island in the ending after the chieftain befriended him.
The Whale makes an appearance in the parade during the credits. It appears floating on a small body of water, with Kolorado and his wife standing on its back. After a couple of seconds, the Whale shoots water out of its blowhole, upon which Kolorado and his wife, standing on the stream, begin waving at the camera.
The Whale also makes a cameo in the Paper Mario stage in Super Smash Bros. for Nintendo 3DS and Super Smash Bros. Ultimate. On the S.S. Flavion portion of the stage, the whale may appear underneath the ship, holding it up in the air by blowing water out of its blowhole.
Names in other languages