Yeah, you need the War Caster feat in order to be able to cast a spell as an opp attack.Besides that, eldritch blast takes 1 action to cast, not 1 reaction, so I don't believe it can be used to make an opportunity attack. The opportunity attack section says an attack needs to be a melee attack, not a ranged attack or spell attack.
To make the opportunity attack, you use your reaction to make one melee attack against the provoking creature. The attack occurs right before the creature leaves your reach.

(Dungeons & Dragons)
Rulebook featuring "high magic" options, including a host of new spells.