i think you are using a pickit (or ICD) to 'program' the PIC, also you power the PIC from the pickit!!!
so when you take out the pickit, of course the circuit will not work...
if your circuit has it's own power supply. mostly it's because you leaved the MCLR pin disconnected... the pickit and any good programmer has the MCLR on high state trough a resistor...
so. if you have a power supply, just connect mclr to vcc with a 10k resistor...
if you don't have a power supply... well... first go and get one!