If you travel through Germany, you'll soon find out that most restaurants and pubs are connected to one single brewery. This is typical because the pubs usually have an exclusive contract with the specific brewery.
You should know - probably you travelled exactly for that reason to Germany - that the beer brewing tradition is one of the main accomplishments of German food culture (besides baking, tart making and sausage production). The oldest, still existing brewery in the world ist the "Bayerische Staatsbrauerei Weihenstephan" where beer is produced since 1040 (!) and the oldest monastic brewery is running since 1050 at Kloster Weltenburg at Kelheim.
In Heidelberg, the brewery tradition is not that old-established. At the beginning of the 19th century 38 breweries in the city, most of them very small ones, supplied the local citizens with "hop juice" ("Gerstensaft" and "Hopfentee" are non-official terms but nevertheless understood by every waitress - as a tourist you'll deeply impress them with your fine sense for the German language ;-))
At the begin of the 20th century only two of them remained "Engel-Bräu" and "Heidelberger Schloßquell", of which only "Schloßquell" has survived to the present day.
"Schloßquell" derives from "Schloß" = the famous Heidelberg castle and "Quell" = spring / well. One nickname for Schloßquell is "Schloßqual" and "Qual" = torture.
Unfortunately Schloßquell is IMHO and in the opinion of most of my fellow beer drinking fellows a middle class beer, in the best case. This is not really a warning, you should give it your own try! And if nobody would like it - hey, they would have been vanished from the market.
Some other local breweries around Heidelberg are Welde (they offer their beer in stylish bottles but the quality is also not really outstanding), Palmbräu (recently bought by Welde, the future is uncertain / their "Unser Bestes" (Our Best) is quite good but the standard brew you'll usually get in the pubs is also more or less middle class). "Dachsenfranz" is a special beer from a small brewery in the nearby little village of Zuzenhausen. If you can find it, try it!
Beer afficionados should definitely try the microbrewery stuff of "Vetter's" Steingasse 9 or "Kulturbrauerei" Leyergasse 6 - both located in downtown.
The main brewery of nearby located Mannheim is "Eichbaum". As most of the breweries, which have become too big, the output of Eichbaum tastes actually like mass production. But this is - as all the verdicts in this article - my personal opinion and taste.
If you're more interested in tasting really great beer look for "Rothaus" or "Alpirsbacher Klosterbräu" - they might be not so easy to find because the breweries are located in the black forrest, 200-300 km away - but they are definitively worth searching for. Cheers!