Hmm, there might be a contradiction. In order for someone leaving 5ft range to provoke an opportunity attack, you'd have to be unarmed, which it sounds like you aren't (shield in one hand, lance in the other) but even if you were unarmed, I don't think that works since Booming Blade requires a melee attack with a weapon. So unless you can remove your lance, then cast the spell, while simultaneously re-wielding the lance so you can attack as part of the casting, I don't see it working.
Opportunity Attacks aren't triggered by someone leaving the reach of one of your weapons, it is triggered by someone leaving your threatened area, which is the area around you you can attack. With a lance wielded, your reach is 10', therefore you threaten a 12.5' radius circle centered on your square (that is, your square and any square within 10' of it). Someone moving from 5' to 10' away from your has left the reach of your unarmed attack, but has not left your threatened area.
I know I'm quite late to the party but I would like to offer some counter arguments.
This string of tweets by Jeremy Crawford suggests you can indeed always make an attack of opportunity with your unarmed strike regardless of whether or not you are using your other hand to hold a weapon. The linked conversation seem to even imply that you have the unarmed opportunity attack option available to you even when you are wielding a two-handed weapon (presumably you can hold it on one hand). Of course, if you are also holding a shield then your DM might not allow an unarmed strike to begin with unless they allow you to drop the weapon/shield as part of the reaction (dropping a shield may be hard considering leather straps and whatnot). Another grey-area of consideration is whether your DM would allow you to punch something effectively when atop a horse while your target is, presumably, on foot. Do not fret though, as these issues are all solved by simply describing your unarmed strike as a kick instead of a punch (allowed as per the unarmed strike text).
The other two parts of the original question here are also full of grey-areas and/or up-to-your-DM type of scenarios. Nonetheless, at least the way I see it, the War Caster feat should indeed allow you to cast Booming Blade instead of performing the unarmed strike opportunity attack (I believe the spell does fit the feat's requirements). The way the feat is worded makes it sound like the spell completely replaces the opportunity attack. In other words, the opportunity attack is foregone, so what weapon's reach was used to determine whether an opportunity attack was triggered becomes irrelevant. What is relevant is that an opportunity attack was triggered, and now that opportunity attack is being substituted by a spell that fulfills the War Caster feat's requirements. At this point, the text on that spell is all that matters. The text calls for a weapon (material cost) and a weapon attack, for which your lance certainly qualifies though the attack roll should be made at disadvantage as per the text describing the lance itself.
So, in a strange way, this could work if left up to a lenient/flexible DM. I'm probably missing something here but these are, at least, my two cents on the topic.
This string of tweets by Jeremy Crawford suggests you can indeed always make an attack of opportunity with your unarmed strike regardless of whether or not you are using your other hand to hold a weapon. The linked conversation seem to even imply that you have the unarmed opportunity attack option available to you even when you are wielding a two-handed weapon (presumably you can hold it on one hand).
Yup! I had not read that string of tweets when I wrote my reply, but yes, leaving the range of any of your melee attacks triggers an Opportunity Attack.