Generation I
It is part of the story line:
After going through the Pokémon Tower and defeating Team Rocket, Mr. Fuji will give the player a Poké Flute in gratitude. The player then uses this flute to progress the game.
The Name Rater is located here.
Generation IV
After restoring the power at the Power Plant, the player is given an EXPN Card, which allows them to use the PokéFlute channel to wake up the Snorlax blocking the path to Diglett's Cave and progress through Kanto.
The Name Rater is located here.
Full details