Let's say I want to land in Minsk, stay there for a few days, and then leave by train to Vilnius.
Where will my migration card be checked upon emigration?
Two trains go from Minsk daily. The first one departs from the Belarusian capital at 7:45 a.m. and returns at 18:10. The second train from Minsk to Vilnius leaves at 18-50, and comes back at 6:05.
What happens, in most border crossings by train is that there's a stop on either side of the border, often at an 'empty' station. Border guards get on the train, and check your paperwork, as well as issuing you with any other paperwork you may need for entry into Lithuania.
Then you carry on to the other side of the border, where a similar process repeats itself.
I would suspect that it's done in Godagai, 10km pre-border, but don't worry - they'll explain it, or just make it happen. Neither country is going to let a train-load of passengers cross the border without checking/issuing paperwork!
Sometimes, as in the case when travelling between Poland and the Ukraine, the rail guage is different, so they do the passport stuff while lifting the train and changing the wheels. It's a very interesting experience.
I haven't done that border crossing, but I've been between Poland and Lithuania, and detailed my experience on my blog, if that's of any assistance.