The rules state that you can take a bonus action at any time unless its timing is specified, in which case you follow the bonus action's own restrictions
You choose when to take a bonus action during your turn, unless the bonus action’s timing is specified [...]
This explicitly details that bonus actions can be taken whenever you want on your turn, and there is no reason this would not include times such as in-between actions that involve multiple attacks.
If a bonus action has a specified timing then you must first satisfy that individual bonus action's timing requirements.
With Two-Weapon Fighting in particular, it depends on whether the trigger is the Attack action or an attack with a light melee weapon
The "Two-Weapon Fighting" section states:
When you take the Attack action and attack with a light melee weapon that you're holding in one hand, you can use a bonus action to attack with a different light melee weapon that you're holding in the other hand [...]
Jeremy Crawford has made the following unofficial ruling (a tweet):
Q. @JeremyECrawford When you take the Attack action, is the trigger for the two-weapon fighting bonus action attack the entire Attack action or a single attack within the attack action? Can that particular bonus action interrupt the Attack action?
A. Here's the trigger for the two-weapon-fighting bonus action: "When you take the Attack action and attack with a light melee weapon that you're holding in one hand …." (PH, p. 195).
Summary: the trigger is the attack that's part of the Attack action, not the entire action. [this summary is part of Crawford's tweet]
Thus, according to Crawford, the trigger for Two-Weapon Fighting is not actually taking the Attack action, but making an attack with a light melee weapon as part of the Attack action. This would mean, according to him, that you can use the bonus action any time after your first attack of the Attack action.
However, the wording of Two-Weapon Fighting isn't the clearest and it might actually be triggered by taking the entire Attack action. If this is the case, we can compare TWF to the Shield Master feat discussed elsewhere:
- If you take the Attack action on your turn, you can use a bonus action to try to shove a creature within 5 feet of you with your shield.
Lead Rules Designer Jeremy Crawford has made unofficial rulings (tweets) regarding the Shield Master feat but ultimately said this:
Clarification about bonus actions: if a feature says you can do X as a bonus action if you do Y, you must do Y before you can do X. For Shield Master, that means the bonus action must come after the Attack action. You decide when it happens afterward that turn.
He also further clarified this here:
No general rule allows you to insert a bonus action between attacks in a single action. You can interrupt a multiple-attack action with a bonus action/reaction only if the trigger of the bonus action/reaction is an attack, rather than the action.
However all of this was then even further clarified with this:
My tweet below was addressing bonus actions and reactions that have triggers. A bonus action that has no trigger—such as Cunning Action and the misty step spell—can take place whenever you want on your turn (PH, 189).
All of these things can be put together to conclude that, according to Crawford, things that use your bonus action or reaction which first require you to "take the Attack action" cannot be done until the Attack action itself is fully resolved. This all would mean that, if Two-Weapon Fighting is triggered in part by "taking the Attack action" then you can use the bonus action only after every attack of the Attack action has been resolved.
How I actually run my tables
I am all for giving my players more options; if they want to break up their Attack action with Two-Weapon Fighting or some other bonus action, I will always give them that option. This is simply because I don't find it particularly helpful to have some bonus actions able to be used mid-Extra-Attack and others could not be based on small differences in wording that the rules themselves don't even cover.
There's a lot of wiggle room for interpretation with the timing of the bonus action attack from Two-Weapon Fighting, so at the end of the day I'd say it falls to your GM. You might also think the it doesn't really matter whether you can use TWF mid-Attack-action, however:
There is an important differences between the attack orderings
Depending on the order of your attacks and what weapon you use, a combatant will have different options. Let's assume the combatant has two weapons, one in each hand, and does not switch out or change weapons. This let's us have the following example of the affects of each interpretation:
If they were to use TWF after attacking with both weapons during the Attack action then they could use either weapon for TWF.
If they were to use TWF after the first attack of the Attack action then they would have to use the weapon they did not just use.