Insulating near a breaker box
Foam board should never be exposed, it should always covered with a fire retardant layer like drywall. So if it is installed correctly, your breaker box would never come in direct contact with the XPS and you don't have a problem.  If it is exposed, then you have a larger problem then just the breaker box making contact with it.