How do the actions work out when sheathing/drawing weapon and then casting a spell?

My character is a Warlock/Fighter with two-weapons fighting speciality. I’m kinda confused with 2 weapons and the spellcasting. All at the same time. So I have the following scenario, please, correct me:

  1. Enter the battle holding 2 weapons.
  2. Sheath one weapon as free action (PHB 190)…
  3. …and cast a spell with S or S/M components using action (or bonus action) with one empty hand.
  4. And finally draw that weapon back. (I’m 666% sure this is wrong, but cannot figure our why)

So what is wrong and what is right?