The winger passed to Leroy Sane, whose long-range effort deflected off Patrice Evra for the 13th-minute opener.
Fourteen minutes later, Man City reached the PL century courtesy of an own goal by their former defender, Pablo Zabaleta.
Aaron Cresswell pulled a goal back for West Ham with a free-kick shortly before half-time.
But Sterling superbly teed up Gabriel Jesus on 53 minutes before cutting back for Fernandinho to make it 4-1 on 64 minutes, leaving City one short of Chelsea's PL-high 103 goals in the 2009/10 season.
The win puts City on 93 points, two adrift of Chelsea's 2004/05 record with three matches left.
West Ham remain 15th, three points above the relegation zone.