USB CDC connection (plug / unplug cable)
The host only starts enumerating the USB device when it knows that it is connected. The connection is communicated to the host by setting a pull-up resistor on the D+ line (for full speed devices). 

The LPC1788 has a USB_CONNECT pin which is used to connect the pull-up resistor using software. See section 11.6.7 SoftConnect in document UM10360 (LPC17xx user manual). For some reason the code setting this pin does not run in some cases I suppose. Maybe this is related to sensing the bus voltage at start up.

My suggestion: Measure the USB_CONNECT pin voltage in the working and non working situations. If they are different, look where in the code this pin is set/unset.