Depends. I would say most are assigned about the time of the trials, with some of the plank crew on board for trials and shakedown. Some ships -- I would think class prototypes, especially, will be under the command of a construction leader during trials, with the plank commander aboard as an observer to learn the new ship.
They would probably fill the lower ranks after the construction is complete with final crew replacements etc. at the time of shakedown.
Figure most of the crew would rotate in and out of the ship as per 'needs of Starfleet' or when possible. Deep range missions that last 10 years would probably have the same crew aboard for a tour, with a change out after that.
But it's your campaign, man -- do it your way.
"War is an ugly thing but not the ugliest of things; the decayed and degraded state of moral and patriotic feelings which thinks that nothing is worth war is much worse. A man who has nothing for which he is willing to fight, nothing which is more important than his own personal safety, is a miserable creature and has no chance of being free unless made and kept so by the exertions of better men than himself."
John Stuart Mill