The Hammers will have to pay €10 million (£7.1m) as a transfer fee to the Italian champions, with another €2m in performance-related bonuses (£1.4m).
Previous reports had credited a number of clubs with holding an interest in the 27-year-old former Torino centre-back.
Angelo Ogbonna stats
Ogbonna is a highly-rated centre-back, but he has struggled to make a huge impact at Juventus since his move to the Italian giants from city-rivals Torino in the summer of 2013.
During the 2013-14 season, the Italian could make just 16 appearances in Serie A, creating 16 chances in the process.
The defender had a pass accuracy of 90%, and won 36 headers, eight dribbles and 16 tackles.
Ogbonna featured in three Champions League matches that campaign, while last season he played just once in Europe's premier club competition.
The former Torino star, though, played in 25 Serie A games for Juventus in the 2014-15 campaign.
Ogbonna created four chances, had a pass accuracy of 89% and a shot accuracy of 22%, and won 41 headers, 15 dribbles and 20 tackles.