It depends on the hero that your playing, how well you know that hero, the team composition to a certain extent, the type of mode: escort, assault, control, the type of game: quick play, competitive, brawls.
If defending (escort) a payload then you need to keep the other team away from it or contest, so even if just two of them chase you then that means there are two who are further away form the payload and it might not move as quickly and if any of your team mates show up then for a few moments it's potentially two less for them to deal with.
If attacking (assault) a payload you want delay the enemy as much as possible, but depending on where the payload is, you need to decide what to do, if the payload is near a checkpoint, and your death will delay it a little then you need to decide whether it's better to delay them to give your team more time to get there or to stay alive to distract them and heal up so that you can take some of them out or weaken them.
On an control map, if it's just you and there are more enemies than you can kill with current health and dexterity, then there's little point in sacrificing your life if the other team holds the objective, but if your team holds the objective try to delay them somehow, staying alive on the objective should be your priority, rather then doing damage, so trying to move around erratically so you can last longer.
Switching roles and strategies aside, if your teams strategy is or seems to be one of those that depends on a role that only you currently fill then you might consider an early death so that you can get back with your team as soon as possible.
Most heroes have abilities that allow them to stay alive or to get away, become intimate with those abilities and use them when you can.