They get inscribed in the Book of Admittance by the Quill of Acceptance:
In a small locked tower, never visited by any student at Hogwarts, sits an ancient book that has not been touched by human hands since the four founders placed it there on completion of the castle. Beside the book, which is bound in peeling black dragon-hide, stands a small silver inkpot and from this protrudes a long, faded quill. These are the Quill of Acceptance and the Book of Admittance and they constitute the only process by which students are selected for Hogwarts School of Witchcraft and Wizardry.
If anybody understands what powerful and long-lasting magic causes this book and quill to behave as they do, nobody has ever confessed to it, doubtless because (as Albus Dumbledore once sighed) it saves the staff tedious explanations to parents who are furious that their children have not been selected for Hogwarts. The Book and Quill’s decision is final and no child has ever been admitted whose name has not first been inscribed on the book’s yellowing pages.
At the precise moment that a child first exhibits signs of magic, the Quill, which is believed to have been taken from an Augurey, floats up out of its inkpot and attempts to inscribe the name of that child upon the pages of the Book (Augurey feathers are known to repel ink and the inkpot is empty; nobody has ever managed to analyse precisely what the silvery fluid flowing from the enchanted Quill is).
Those few who have observed the process (several headmasters and headmistresses have enjoyed spending quiet hours in the Book and Quill’s tower, hoping to catch them in action) agree that the Quill might be judged more lenient than the Book. A mere whiff of magic suffices for the Quill. The Book, however, will often snap shut, refusing to be written upon until it receives sufficiently dramatic evidence of magical ability.