Is it the mechanical portion or the switch plunger itself that is sticking? If the plunger then I'd try dry silicone spray.
I'd try lubing it before replacement, but first I would try to get some of the muck off, with a paint brush or compressed air.
Next I'd try something meant for lubrication which isn't WD-40, but if WD-40 works, then it works... Light rattle can grease would be my first choice, depending on where it's sticking. If it has old hardened grease causing a problem, then possibly the WD-40 just as a solvent to loosen the old grease, and then rattle can grease. However, this switch has exposed contacts, or not? If it has exposed contacts then spray grease might get into the contact area and is better avoided.
If that doesn't work, once you remove it, unless you see something more you can do/better, then go ahead and replace since they aren't expensive and brake lights are kind of important for safety.