"... highly exciting possibilities were open to us now that we could all transform. Soon we were leaving the Shrieking Shack and roaming the school grounds and the village by night. Sirius and James transformed into such large animals, they were able to keep a werewolf in check. I doubt whether any Hogwarts students ever found out more about the Hogwarts grounds and Hogsmeade than we did ... And that's how we came to write the Marauder's Map, and sign it with our nicknames. Sirius is Padfoot. Peter is Wormtail. James was Prongs."
-- Remus Lupin (PA18)
Sirius Black, Remus Lupin, Peter Pettigrew, and James Potter explore the castle and grounds in their Animagus forms and learn more about the secrets of the place than anyone, even Filch. They then create the Marauder’s Map, signing it with their nicknames: Moony (Lupin), Wormtail (Pettigrew), Padfoot (Sirius), and Prongs (James).
We don't know exactly when this happened, but it was around the beginning of the Marauders' sixth year.