If you are committed to your travel dates and times, then you can only gain (save) by booking (90 days) in advance.
This is what the man in seat 61 says for Austrian train travel ...
The ÖBB (Austrian Federal Railways) website is www.oebb.at - for ticket sales use https://tickets.oebb.at and switch it to English.
Seat reservation is optional on most Austrian internal trains, you can always just buy a standard price ticket at the station, hop on the next train and sit where you like. Trains cannot 'sell out'. But if you want to be 100% sure of a reserved seat on a specific train you can make an optional seat reservation on InterCity, EuroCity and Railjet trains for a small additional charge, around €3. And for cheaper tickets, book in advance.
Advance-purchase Sparschiene fares
Until a few years ago there was no price advantage in pre-booking, there was just one fixed standard price. But in 2011 ÖBB introduced yield-managed dynamic pricing which means you can now save money if you book a Sparschiene (saver) fare in advance and commit to a specific train on a limited-refunds, no-changes-to-travel-plans basis. ÖBB's Sparschiene fares between Austrian cities start from just €9 upwards and vary with demand and according to how far ahead you book.
You can book online at https://tickets.oebb.at - it has an English version - and you simply print your own tickets.
The train operator in Germany is DB (Deutsche Bahn).
See www.bahn.de for train times, fares & online tickets within Germany.