Pence also scored two runs in support of Brett Myers (2-2), who gave up two runs on eight hits and struck out three in six innings.
The victory was the second in a row for the Astros, who had previously lost three straight.
Brad Penny (3-3) took the loss, giving up four runs -- all unearned -- on seven hits over seven innings. Penny was in control with a 2-0 lead through six innings, but Houston pounced for four runs in the seventh to take control.
After Ludwick drove in a run to make it 4-3, Pence and Berkman added insurance runs with solo home runs in the eighth.