I've got a character with the Dueling fighting style who fights with a rapier while keeping their other hand free. They also have a dagger sheathed.
The way I see it, my character can perform a regular attack with the rapier (and get +2 damage from Duelist), then as a free action my character can draw a dagger and make a bonus-action attack with it. At the beginning of my next turn, I've got both hands occupied, so in order to get the Dueling bonus, I just sheathe my dagger.
But my DM says that I can't attack with my other hand free and then draw a dagger before the bonus action, meaning that if I draw a weapon, I do it as part of my regular attack (therefore losing +2 damage since I have a dagger in my off-hand).
The rules don't seem to clarify this situation.
Can I draw my second weapon before the bonus-action attack, but after my initial attack?
Best Answer
Update October 2020: No
As user @V2Blast mentions below, the Sage Advice Compendium page 13 explicitly rules "No" for this question. Page 13:
Original Post
No, you cannot draw your dagger and attack with it while retaining your Duelist feature
But you can draw your dagger as part of an attack and then use it.
The core argument behind this answer is that you can only attack as a bonus action with your offhand weapon when you use your action to attack.
You don't have this bonus action otherwise.
You can draw your weapon as part of an attack...
...but that would remove your +2 bonus
So, here is what you are trying to do.
You attack
You can use Two-Weapon Fighting to attack with a weapon that is already in your hand. You can subvert this by drawing your weapon as part of your aforementioned attack declaration.
Since you now have another weapon in your hand, you lose the Duelist feature of +2 damage.
If you forgo drawing your dagger, you are not allowed a second attack since the dagger is not in your hand during your attack action. It's either one or the other, you cannot combine two-weapon fighting and duelist in the same attack action. You can dual wield and drop your dagger as a free action before you attack with it to retain your Duelist bonus for the next turn (turn start, attack with no bonus, attack with dagger, turn end, turn start, drop dagger, attack with bonus)
If you need a logical reason for why this has to be, you can think of a duelist as sort of "fencing" with his body turned to the side, putting all his focus on the one weapon. Dual Wielding is less precise and doesn't allow your character to focus on the one attack, but spreads his focus out over two weapons.
One final note, you cannot use your Rapier for Two-weapon fighting because it does not have the light attribute, unless you have the Dual Wielder feat.