You can take a bonus action only when a special ability, spell, or feature states that you can do something as a bonus action. Some examples are:

  • Offhand Attack.
  • Casting a Spell with a Cast time of 1 bonus action.
  • Using certain class features.