Can I draw a weapon before making a bonus-action attack and get the damage bonus from the Dueling fighting style?

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?