How to build a USB charger circuit that can switch between the USB and the battery power automatically?
"I wanted was to be able to drain the power from the USB port up to 500mA and the remaining would come from the battery."

An analogy: Your car has a battery. It is charged from the alternator. All power used is coming from the battery, BUT if the battery is somewhat discharged (say you just started it in sub-zero weather,) you will get power from the alternator but it comes through the battery. (Of course if the battery is completely discharged you will need to run the engine for 30-60 minutes so the alternator can recharge the battery with enough energy to start the engine the next time.)

If I'm reading the datasheet correctly the LTC4055 is very much like an car's alternator. Have your PCB connected directly to the battery. The LTC4055 can be attached between the USB and the battery. 

The question then becomes what happens if the battery is completely discharged?

Can the LTC4055 supply sufficient current to recharge the battery while letting the USB port power the PCB?  Again referring to the datasheet the LTC4055 goes into a low current trickle charge mode if your battery is completely discharged and the rest of the USB current goes to load. Sounds like it is the right approach, or at least worth trying.