The only way from Kraków to Berlin Anhalter Bf is by flight. You should expect to be able to find tickets starting around $293, if you search flights from KRK to SXF. The best time to book shorter flights is 2-3 weeks before your trip.
On your trip from Kraków to Berlin Anhalter Bf, it is best to book as soon as possible. It won't necessarily help reduce your price by a large amount, but will ensure that you have a spot on the bus or train.