The fourth-place Hammers, as a result of their fifth victory in 10 games, opened up a seven-point gap over City in fifth, although Leicester have played one game fewer.
West Ham took the lead on 39 minutes as Veron Parkes converted a spot-kick at the Club's training ground before the 18-year-old doubled his side's lead six minutes into the second half.
Parkes turned provider later on, laying it up for Sebastian Nebyla to make it three for West Ham, but Connor Barrett was able to narrow the deficit with eight minutes to play.
Following a Premier League Cup group stage game against West Bromwich Albion on Saturday 23 November (11:30am kick-off), the young Foxes return to league duties on the last weekend of the month.
They welcome sixth-placed Tottenham Hotspur to Belvoir Drive on Saturday 30 November (11:30am kick-off) before facing Aston Villa away on Saturday 7 December (11am kick-off).
The details
City: Bosworth (c); D. Gyamfi, Barrett, Sams, Aisthorpe; Maswanhise, Loughlin, Leathers, Fitzhugh, McAteer; Russ
Subs not used: Doherty, Murch, Marcal-Madivadua, Yfeko, Pennant
Goals: Barrett 82'
All times GMT.