Two penalties in the final 15 minutes secured the Hammers' passage into the quarter-finals at the expense of the Championship leaders, who had previously won eight games on the bounce in all competitions.
Kevin Nolan, introduced to the action by Allardyce on 71 minutes, won the first spot kick, which was converted by Matt Taylor, and Jack Collison, a half-time swap for Mohamed Diame, netted West Ham's second from 12 yards.
Allardyce told reporters: "The introduction of first Jack Collison at half time then Stewart Downing, then Kevin Nolan as the game went on meant our quality of player got better and our quality of passing got better and better.
"In the end we were very, very happy that we won and I'm very happy with the team and the effort the players put in."
Tuesday's result was the first time that Burnley had been beaten in a home League Cup tie in 10 matches.