If the switch is on the transmission, the problem could also be that the shift cable / linkage is worn or out of adjustment, so moving the shifter to Park doesn't actually move the transmission (and switch) all the way to Park.
As car problems go, this one is rather inexpensive to fix and also...