Are you running from an ICSP ? .... The reason I ask, is that some PIC's are aware of a Reset Condition versus a Cold Start. Some ICSP will make the PIC think it started from a Reset after programming. My PicKit3 does this.
PDF Reference:
https://ww1.microchip.com/downloads/en/DeviceDoc/40001303H.pdf
From the PDF page 27 .... "On device Resets, the output frequency of the internal oscillator is set to the default frequency of 1 MHz."
Also see page 33
I'm not familiar with this particular PIC, but I have seen plenty of others... I usually do something at the very beginning of my code that forces or resets the the PIC to the desired speed.