Will this work and what transistor do I use?
You've drawn an NPN transistor as a high-side switch. This won't work since you need to drive the base at least 0.7V higher than the emitter, and your RPi GPIO outputs only push 3.3 volts.

You should move the transistor into the ground path to operate as a low-side switch, and add a current limiting resistor to the base. Even then, you will probably run into trouble depending how much current the lamp needs compared to the h_fe of the transistor, necessitating two BJTs in a Darlington configuration.

I would recommend ditching BJTs altogether and using an N-channel MOSFET as a low-side switch. MOSFETs are voltage controlled devices, so you just need to supply a logic level to the gate to get it to operate as a switch. Add a pulldown (say 10k) from the gate to the ground so the input doesn't float when the RPi is off or Hi-Z. Something like this:







simulate this circuit &ndash; Schematic created using CircuitLab

When choosing a MOSFET, pick one which can handle the current without a heatsink (say 1A), and ensure that it can switch using a 3.3V gate drive.

Finally, 600 mA is more current than most standard USB ports can handle. A USB charger can do this, but a standard USB 2.0 port is limited to 500 mA. So, be careful what you plug this into.