With that line of thinking you had better do all of your scenery first and then lay the track. After all, that's how the real world works.
If you wish to call in the miniature diggers to prepare the ground then by all means do lol..
I did of course mean after the track is laid.. Ballasting should be pretty much the the last major thing you do..
I'll clarify myself a little.. We'll presume that were building a flat layout.. After preparing the road bed with cork, foam lino, what ever your choice is, paint the ground with a cheap emulsion, we'll say brown for standard earth tone, a Mocha or coffee colour is good..
Once that's dried, we then lay the track.. You can weather the track before or after laying, totally down to personal choice..
Once the track is down, mask off the edge of the rails, slightly wider than the sleepers/ties (about 3-4mm in HO) then start to apply your ground cover in what ever way you prefer, then remove the masking tape..
Once this ground cover has dried, you then have a slight shoulder which will stop your ballast from spilling all over the place and moving when you apply it & the fixing medium (normally white glue & water although some people use different products)..
Once this has dried and you have cleared off the excess, you can then add any stain/colouring that you wish too to the ballast, this really is down to personal choice.. Like wise is adding any weeds to the track or surrounding wayside..
The logic behind it!
It's all about layers.. It's quite simple really, you can't go backwards, well, not without a lot of effort anyway.. You can't paint under the sleepers/ties once their down or once you've ballasted and certainly not without a lot of effort not to ruin everything else around it.. Remember, your mimicking/recreating the real world, so simply think about what was there first - the chicken or the egg!?!

lol...