The defender's good form this season has earned a deal which ties him to the club until the summer of 2016.
His previous contract was due to expire at the end of the current campaign.
"I am delighted," O'Brien told West Ham's website. "It's for three-and-a-half years so hopefully I'll have plenty more good times with the club."
Free-transfer O'Brien has established himself as a first-team regular since becoming one of Sam Allardyce's first signings at the Boleyn Ground in July 2011.
The Republic of Ireland international, who previously worked with Allardyce at Bolton, has scored twice in 16 Premier League appearances this term.