With the score tied 1-1 in the bottom of the ninth, Bonifacio delivered a leadoff double against Jose Cisnero (2-2).
Encarnacion drove in Toronto's other run and Melky Cabrera added three hits as the Blue Jays took three-of-four games from Houston.
Casey Janssen (3-0) earned the victory after starter Todd Redmond had struck out 10 Astros over six innings, allowing one run.
Houston's Jarred Cosart also tossed six innings of one-run ball, working around five walks and four hits.
Brett Wallace smacked a solo homer for the Astros.