Its a toss-up
Since you make an either-or proposition, I think Heidelberg edges by a hair. To do Heidelberg, 1 day should be sufficient, spend the second day to tour the Neckar river valley (assume you have wheels).
The Heidelberg Castle is what draws tourist here. But I found that the old town area with its Marktplatz is quite interesting, dotted with colorful buildings, winstubs and restaurants. It has several museums (being a university town with Germany's first U established here) in town. There is a good walk through the university campus and then across the Alte Brucke (Old bridge) to the castle. As previous post mentioned Heidelberg being touristic, that it is. But at night, the town is very nice and quite with all the tourists gone.
As for Trier, it is known for its Roman relics. If you are a student of Roman architecture and arts, Trier can be a great 1-day destination. Spare the next day driving along the Mosel river all the way to Koblenz (RT takes 1 day). I think the Mosel valley is worth touring. Again, it is best done with a car. Barring driving, trains and boats are open options.
Whatever you decide, have a great trip!