West Ham and Anderlecht met in the 1975-76 European Cup Winners' Cup final when the Belgian side won 4-2 in Brussels.
The Hammers, Europa League semi-finalists last season, have also been paired with Romania's Bucharest-based FCSB and Danish side Silkeborg in Group B.
FCSB were previously known as Steaua Bucharest, who were crowned European champions in 1986.
Drawing Silkeborg means a quick return to Denmark for West Ham, who won 3-0 at Viborg on Thursday to complete a 6-1 play-off aggregate win.
David Moyes welcomed West Ham's draw, saying: "I've just seen it and it's good. I'm looking forward to it. There are some good teams in it.
"We've had quite a difficult draw with our group but we're looking forward to it."
Hearts look to have a tough-looking section in Group A.
Robbie Neilson's side saw their Europa League ambitions dashed by a 3-1 play-off defeat to Zurich on Thursday.
Hearts will now play Istanbul Basaksehir, Fiorentina and Latvian champions RFS.
Istanbul Basaksehir, who progressed to the group stage with a play-off victory over Antwerp, include former Arsenal midfielder Mesut Ozil and Aston Villa loanee Bertrand Traore in their ranks.
Fiorentina finished seventh in Serie A last season and beat Dutch side Twente 2-1 on aggregate to reach the group stage.
Shamrock Rovers have been paired with Gent, Molde and Djurgardens in Group F.