From where are you starting? How many people? What do you want to see in each of these towns? Train or Car? Do you want to see both towns in one day?
Train don’t want to drive
... and please be aware that from Dec 24 to Dec 26, many places might be closed (check the websites before you go), and for restaurants that are open, reservations are recommended.
Both cities in one day is really stressful! Maybe you can take two days?
If not then start your trip with speyer and from there to Heidelberg. Just remember there is no fast train between speyer and HD.
Thanks everyone all great thoughts. Very much appreciated