There is no easy solution to your problem. If the main power is OFF to the PIC, then it can be powered via any of it's input pins through it's internal protection Diodes.

Easiest and cheapest solution is to power the PIC at all times, but when it is not needed, put it to SLEEP to conserve Battery power.

Otherwise you will have to devise additional circuitry to disconnect all independently powered pins from the PIC when it needs to be switched OFF. If you only have ONE independently powered and connected pin, then a single 5v Reed Relay is the easiest solution... when the PICs supply is disconnected, the Relay will disconnect your input.