Your problem lies with the line

__config _INTRC_OSC_NOCLKOUT

The "_INTC_OSC" part means to use the internal oscillator.

You should change this to "_XT_OSC" instead