West Ham seemed destined for a third successive clean sheet in the competition as a dour match headed for a goalles draw, only for referee Jonathan Moss to penalise Mohamed Diame for shoving Glenn Whelan in the 82nd minute.
Pennant, who had recently arrived on the pitch, curled the free-kick over the top of the wall and beyond the reach of keeper Jussi Jaaskelainen to secure Stoke's second Premier League victory of the season.
The better football was played throughout by Mark Hughes' side with Kenwyne Jones, starting ahead of Peter Crouch, Marc Wilson and Jonathan Walters failing to convert first-half chances.
Wilson and Walters were only denied by a magnificent double save from Jaaskelainen when a goal seemed certain.
West Ham finally discovered some urgency in the last 20 minutes, but they were still incapable of troubling keeper Asmir Begovic and two Premier League matches have passed without them scoring.
The return of Andy Carroll, out with a heel injury, can not come soon enough and the England striker is expected to be available for Southampton on September 15.
This performance may convince Sam Allardyce that reinforcements are needed before the transfer window closes on Monday, while in contrast Hughes must be pleased with the early progress he is making at Stoke.
The visitors' superiority was evident from the start as they moved the ball forward purposefully.
Jones ran almost half the pitch as his strength took him past Kevin Nolan and when James Collins arrived to provide pressure, he skied his shot into the stands from 15 yards out.
Source: PA
Source: PA