St Thomas Aquinas covers this question (more-or-less) and I don't think you're going to find this in the Catechism. I think someone smarter than me will have to interpret it for you.
Therefore those who are ordained to possess eternal life through divine predestination are written down in the book of life simply, because they are written therein to have eternal life in reality; such are never blotted out from the book of life. Those, however, who are ordained to eternal life, not through divine predestination, but through grace, are said to be written in the book of life not simply, but relatively, for they are written therein not to have eternal life in itself, but in its cause only.
So there's two times when the writing takes place once for those who St. Paul called predestined:
For those he foreknew he also predestined to be conformed to the image of his Son, so that he might be the firstborn among many brothers.
and once for those who drink the waters of eternal life later on.
but whoever drinks the water I shall give will never thirst; the water I shall give will become in him a spring of water welling up to eternal life.”
And the writing in the book, St. Thomas says should be taken in the Metaphorical sense:
The book of life is in God taken in a metaphorical sense, according to a comparison with human affairs. For it is usual among men that they who are chosen for any office should be inscribed in a book; as, for instance, soldiers, or counsellors, who formerly were called "conscript" fathers