Houston's Fernando Rodriguez (1-8) walked the bases loaded with none out in the 10th, prompting the Astros to play the infield in.
Hart then stroked a sharp grounder that got past third baseman Matt Dominguez. Shortstop Jed Lowrie fielded it, but couldn't make a throw as Nyjer Morgan crossed the plate with the go-ahead run.
Rickie Weeks (3-for-5, two RBI) added a run-scoring single to cap the inning and send the Brewers to a victory in the rubber match of their three-game series.
The Brewers forced extra innings when Ryan Braun singled home the tying run in the eighth.
Jose Altuve, J.D. Martinez and Chris Snyder knocked in runs for Houston.
2014: The Year in Music [PHOTOS]