The Hammers beat Barnsley to secure their place in the draw, while Forest overcame boss Billy Davies' former club Preston.
The tie will take place on the weekend of January 29/30.
Source: PA