Yes. Pepper spray should be tested once every three to six months. You can test the spray outdoors, shooting off one spray to make sure the canister is still functioning.
If you have a small keychain canister, you may need to replace it annually, since these canisters don’t hold much spray.