Yes microchip gives you something called a USB framework, Its a big pile of C code librarys, some of it takes care of transfering the bits over USB and responding to the PC corectly. That pice of code you dont realy need to understand.
Then there is the code that makes the USB acualy do something useful like for exsample the CDC driver that makes a com port and the file that contains the USB identifier. The idenditifer file is a pile of strings that the PIC sends to the PC when its pluged in. They tell the PC everythyng about that device from the manufacruter to its name and to what it is and what the device can do.
You can look trough the CDC exsamples main to see what its doing, that file also has a pile of callback subrutines that get called by the USB library on certan events like standby or initalization complete and such.
One thing to watch out is that you need to call a rutine to service USB reqests from the PC every few ms or the USB device becomes unresponsive.