Pep Guardiola's men are in search of an unprecedented fifth successive triumph in the competition and they will face the Hammers, who beat City's rival Manchester United 1-0 in round three.
Arsenal cruised to a 3-0 victory over League One AFC Wimbledon and it takes on Leeds at the Emirates Stadium next after Marcelo Bielsa's side edged past Fulham on penalties.
There are five all-Premier League ties in total, with Leicester City pitted against Brighton and Hove Albion after being defeated at the weekend in the top flight by Graham Potter's men.
European champion Chelsea needed penalties to sneak past Aston Villa and it will host Southampton, which also required spot-kicks to defeat Sheffield United.
Burnley crushed Rochdale 4-1, but a much tougher task awaits as it faces Tottenham after its shoot-out triumph over Nuno Espirito Santo's former club Wolves, while Brentford meets Stoke City away from home in the next round.
Liverpool makes the trip to Deepdale to do battle with Championship side Preston North End, which demolished Cheltenham Town 4-1.
There will be at least one non-top-flight side in the last-eight stage as Sunderland faces Queens Park Rangers after Mark Warburton's men upset Everton.
The fourth-round clashes are set to take place during the week commencing 25 October.
Carabao Cup draw:
Chelsea v Southampton
Arsenal v Leeds United
Stoke City v Brentford
West Ham v Manchester City
Leicester City v Brighton and Hove Albion
Burnley v Tottenham
Queens Park Rangers v Sunderland
Preston North End v Liverpool