The Republic of Ireland international who had previously worked under Allardyce at Bolton, had been training with the Hammers during pre-season and has now agreed terms on a permanent deal.
Together again: O'Brien (right) has been reunited with Kevin Nolan (centre) who has also joined the Hammers
O'Brien, 25, becomes Hammers boss Allardyce's fourth summer signing after Kevin Nolan, Abdoulaye Faye and Matt Taylor all agreed to join the Upton Park club.
The midfielder told the club's official website: 'Obviously I'm delighted to finally sign because I've been here since the start of pre-season.
'It's been a few weeks now and it's gone well. The manager wanted me to sign and as soon as I heard that, there was no real hesitation.'
Allardyce is rumoured to be chasing a fifth former player, full-back Jllyod Samuel who played 79 minutes during the Irons 2-0 win over Real Zaragoza.
?Bolton suffer Lee injury blow after influential midfielder is carried off in friendlyReo-Coker sets sights on England call-up after completing move to BoltonAll the latest Bolton news, features and opinion
Source: Daily Mail
Source: Daily Mail