jon and bob's answer has the right idea. I have DM'd D&D games for over ten years and I can see the devs slowly working towards resolving some of the glaring issues that are present in the game mechanics. That said, they cannot account for everything. That is why, in every single chapter of the Player's Handbook, you are explicitly told that the RAW are intended to guide character creation and gameplay, not constrain it.
If you're wielding a two-handed weapon and you have the War Caster feat, the rules say that you can still cast the spell (I imagine, in the example case of the burning hands spell, it would involve pouring magic into your sword, limning it with flames, and then swinging the sword in a large arc that sends the flames out in a cone). Without the War Caster feat, I wouldn't say that you would have to drop the two-handed sword, only that you would have to balance it in such a way (say, against your shoulder) that you can get a free hand to cast the spell. I would then say that you make opportunity attacks with disadvantage until the start of your next turn because you had to sacrifice proper sword-fighting form in order to cast the spell. Of course, if it's a more complex spell such as a ritual in which you need to do tasks that would reasonably require two hands, then you should be putting away your sword.
Again, this isn't necessarily RAW, but you are told dozens of times throughout the PHB that the RAW are not always comprehensive enough to account for the variety of circumstances that occur in a game. Discuss it with your DM to make sure you are both on the same page. He or she may decide that you can't take any opportunity attacks with a two-handed weapon if you have cast a spell in the previous turn without the War Caster feat. Don't be afraid to come up with an independent solution (sometimes pejoratively called a "house rule") for situations like this. There's nothing wrong with making up an answer in order to clarify gameplay, especially if perusing the books and querying on the internet would hold up the game. And don't be afraid to make rulings that favour a player's convenience. Remember that the characters are the highest calibre of heroes (or anti-heroes) who are capable of exploiting every advantage they can find in order to increase their odds of survival and success.