That depends on your use case.
if you want to create a little RPG world, say a dungeon or something similar, that could easily be done in one go when the game starts up.
For huge, "endless" procedural worlds like Minecraft, you'll usually generate the specific parts of the world around the player (also called chunks) on the fly and unload these when the player is far enough away, for memory and performance reasons.