West Ham's job was made more difficult when Fabian Balbuena was sent off 10 minutes before the end.
Chelsea and West Ham are both vying for a Champions League spot and with Liverpool dropping points against Newcastle United earlier in the day, a result for either team at the London Stadium became even more important.
The result leaves Thomas Tuchel's side in fourth place, three clear of West Ham and four clear of Liverpool.
"The win was well deserved. We played amazing in the first half," Tuchel said after the game.
"We did not come out of the dressing room with the same intensity as in the first half. We suffered a bit with their intensity, but I think we deserved to win. It's a very important win."
Werner, who has struggled at Chelsea since joining them last summer from RB Leipzig, scored a well-worked team goal after 43 minutes.
The Germany international took the ball out of the midfield and played it out left to Christian Pulisic. Ben Chilwell then squared the ball into the box for Werner who powered his shot past Lukasz Fabianski.
The goal came against the run of play with West Ham not dominating in possession but looking strong in defence.
Werner could have had a second approaching the hour mark but he skewed his shot wide rather than chipping it over Fabianski.
A VAR check on 81 minutes showed that Balbuena had raked his studs down Chilwell's leg in a poor tackle and he was sent off.