When carrying bear spray, it’s important to remember that it is a weapon. It is not meant to be used on well-behaving bears just doing “bear stuff.”
There are a number of situations during which deploying bear spray would be appropriate. The most obvious is a charging bear. Another may be if a bear in the area in which you are hiking begins acting in a predatory or threatening manner. A third would be a bear that has invaded your campsite looking for food and other goodies during a camping trip.