The 25-year-old arrives on a free transfer after being released from the Reebok Stadium at the end of last season.
O'Brien, who was on loan at Sheffield Wednesday last term, has impressed Allardyce throughout West Ham's pre-season and now becomes his fourth new signing, joining Kevin Nolan, Abdoulaye Faye and Matt Taylor at Upton Park.
"Obviously I'm delighted to finally sign because I've been here since the start of pre-season," he told the club's official website.
"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 also weighing up the signing of a fifth former Bolton player, full-back Jlloyd Samuel, who is playing in Saturday afternoon's friendly against Real Zaragoza.
Source: Team Talk
Source: Team Talk