A creature has one bonus action per turn in 5e, regardless of how many actions it has. You can take a bonus action when a spell, feature, or feat says you can use it as a bonus action; otherwise, you don’t have a bonus action to take.
You can only take bonus actions on your turn. You can take the bonus action at any time during your turn, unless the bonus action specifies otherwise. For example, the Shield Master feat allows you to Shove as a bonus action only after you have taken the Attack action. Similarly, a Monk’s Flurry of Blows requires a player to take the Attack action in order to make two unarmed strikes as a bonus action.
Most of the time, however, bonus actions can be taken at any time during your turn, as with features like a Rogue’s Cunning Action and all spells with a bonus action casting time.
Importantly, anything that prevents you from taking an action on your turn also prevents you from taking a bonus action. This includes if a creature is
-
Petrified
-
Unconscious
Player’s Handbook, page 189
Is There Any Way to Get More Bonus Actions in 5e?
No, there is no way to get more bonus actions per turn in 5e. You are always limited to one bonus action per turn, regardless of what features your character has. For example, a spell like Haste or the Fighter feature Action Surge grants additional actions. However, they do not grant additional bonus actions as well.
There is one slight exception to this. Thief Rogues get a 17th-level feature, Thief’s Reflexes, that grants an extra turn on the Rogue’s first round of combat. The Rogue can take one bonus action on each of these turns, resulting in two bonus actions in one round of combat. Still, the rule of one bonus action per turn is never broken.