"Not too long ago, I was in the biggest slump," he said.
"Now, I've caught a good streak and I'm hitting the ball well."
Pence hit a two-run homer and an RBI double in the finale for the Astros, who've won eight of their last nine home games. Michael Bourn drew a bases-loaded walk from Chan Ho Park to force home the go-ahead run in the seventh inning.
Jose Valverde pitched a perfect ninth for his 22nd save in 26 chances and the Astros matched their longest winning streak of the season at four.
"We got a good start to the homestand," Pence said. "It all starts with pitching. The bullpen did great and we battled as hitters."
Ryan Howard and Raul Ibanez hit back-to-back homers in the fourth against Houston starter Brian Moehler. Howard also drove in a run with a first-inning single.
The Phillies still have a comfortable lead in their division, but manager Charlie Manuel is worried that his players are starting to press as the team heads into the final month.
"I don't know what it is, if they're tight or whatever," Manuel said. "They have no reason to be tight, but I kind of sense that's what it is.
"This is September 7th. We're still in good position, but we've got to play, man, we've just got to play."
The Phillies scored only 10 runs in Houston and were swept in a four-game series for the first time since August 2008.
"It was a bad series and that's saying it lightly," Manuel said. "We did everything we could to lose. You name it, every game, we did everything we could to lose."
Jamie Moyer became the Phillies' last-minute starter when J.A. Happ was unable to pitch because of a right oblique strain. Moyer got a no-decision after allowing two runs and three hits in six innings.
With the Phillies leading 1-0, Moyer walked Miguel Tejada in the second and Pence drove a full-count pitch over the railroad tracks in left. Pence is hitting .394 with four homers and 10 RBIs in his last 10 games.
"It's just baseball, you can't explain it," Pence said.
"Hopefully, I can keep riding it, keep going in there, trying to get a good pitch and making a good swing."
Howard and Ibanez homered in the fourth, the second time this season the two sluggers have connected in consecutive at-bats.
Moehler walked Ibanez and Jayson Werth with two outs in the sixth and Sammy Gervacio relieved. Pedro Feliz walked on four pitches to load the bases, but Gervacio got Carlos Ruiz to fly out.
Moyer retired 11 in a row after Geoff Blum's single in the second inning.
Bourn led off the Houston sixth with a line-drive single up the middle that Moyer ducked to avoid. Moyer retired the next three hitters to wrap up his 101-pitch outing.
Wesley Wright (3-2) replaced Gervacio in the seventh. He gave up a double to Jimmy Rollins, but got the final two outs.
Park (3-3) relieved Moyer in the seventh and the Astros tied it on back-to-back doubles by Tejada and Pence. Park then walked three straight batters to give Houston a 4-3 lead.
Tim Byrdak and Jeff Fulchino combined to shut out the Phillies in the eighth, setting up Valverde for the finish.