How to wire a PIC32MX795 so it can be used as a Host (OTG) or device
There is a development kit microchip that performs with all the technical features that you require, it is USB Starter Kit II



In the picture I have marked the 3 USB ports (1 debug only) and the jumper to select the power source

The kit is very good documented, the datasheet contains all the schematics and there are numerous "Application Notes" on how to realize both the hardware this software. It can be used as the basis, for your study.

If you did not find any interesting application with its own code of microcontroller, can try to search in other families as PIC24F and PIC24H
will notice that with a few changes in the layer configuration of hardware will be able to reuse the code without any problems.

In addition I can tell you that there are many more open hardware projects, based on PIC32, with careful research on the Internet will be able easily locate other schematics and application notes.