The 21-year-old made seven appearances for the Hammers and netted his only goal for them in a Europa League qualification round match against Andorran side FC Lustrains last season.
Lee had two loan spells in League One last term, with Blackpool and then Colchester United.
He scored twice for the U's but was unable to save them from relegation.
The length of Lee's contract with the promoted Tykes has not been revealed.
Find all the latest football transfers on our dedicated page.
Barnsley have signed striker Elliot Lee from Premier League club West Ham United for an undisclosed fee.