If you had to choose one of these two. Which would you choose for 2 days? Family trip.
That's very difficult to answer because everyone is different. And comparing Baden-Baden to Heidelberg is like comparing apples to oranges. Baden-Baden is a town in the Black Forest that is known for its natural hot thermal springs, and can get very crowded in the summer. Heidelberg, on the other hand, is a beautiful city set in a lovely setting and with a lot of history and interesting architecture.
They're both worth a visit, but if you can only choose one, pick the one that interests you the most. I would definitely pick Heidelberg, but that's me. I like cities and I like history and I like architecture. You do you and choose what interests you. If you like relaxing in a hot spring and staying in the Black Forests with lovely scenery and other small towns to visit, then go for it, but if you'd rather see an interesting city with a lot of history, then go for Heidelberg.
So basically, please tell us when you will be there, how many are going, and what the respective approximate ages are (i.e. two adults plus two teenagers, et cetera). And let us know what your interests are. The more information you give us, the better an answer we can give you.
Heidelberg, hands down. It's not Germany's greatest city, nor is the castle there terribly interesting, but it does have an enjoyable and mostly well-preserved old-town zone as well as a fun "Bergbahn" to the peak that overlooks the immediate area:
https://www.bergbahn-heidelberg.de/en/Home/Welcome-to-the-Heidelberger-Bergbahnen.html
And nearby are some nice places to visit...
Hirschhorn: https://img.fotocommunity.com/hirschhorn-am-neckar-a65c6bd3-3a61-4461-992a-1cba6afa5e9e.jpg?height=1080
Bad Wimpfen: https://www.visit-bw.com/en/article/old-town-bad-wimpfen/8502d11c-49cf-4259-8727-d4e7a269aab9#/
Burg Guttenberg: https://burg-guttenberg.de/en/
Baden-Baden's bread and butter depends on gambling, spa treatments, and high-end shops. And visiting other towns from there by train is very peculiar - it requires a preliminary 20-minute bus ride just to reach the town's train station. (And of course you have that same bus ride to get to the town center in the first place when you arrive at Baden-Baden station.)
Heidlberg!
I have only been to Baden-Baden and it is a lovely small town I have not been to Heidelberg. If I was the one who had to choose which city to go to I would have key things to consider:
Where are you coming from to get to each place. How long is the route you are taking ( train, car, bus) to get to one of these cities? Time between places is an important factor when you may have limited time in a country and you don't want to spend a lot of time getting to your city. Where are you going after your visit to one of these cities, is it easy to get to the next city you want to visit.
Have you looked on YouTube to see what each city looks like, great way to see a city without going there and see what peaks your interest. Have you looked at YouTube because they will show you what there is to see and do in each city, along with hotels in each city.
Have you read the RS guide books that tell you what there is to see and do along with other guide books.
Have you looked at Instagram, I have found places to go to, cafes that I found that I loved, it has tons of photos of each city to reference and save in a folder.
I hope this helps.
Heidelberg is a University town with a large percentage of the non-tourist crowd being under 30 years of age. There's a lot more geared towards people that age in the way of shops and food, although there's also a lot aimed directly at tourists, because it's a very popular place. There's plenty to see over 2-3 days in Heidelberg, but there's an enormous amount of stuff within an hours ride by train. Mannheim, Speyer, Mainz, Frankfurt, all of the wine country just west of the Rhine, etc.
Baden-Baden is where old people with money go. It's stuck in a narrow valley, it's attractive, but it's not especially friendly to just walking around.