Transistor how to turn lamp on/off
Your circuit will function correctly and do what you expect.
The transistor you have is intended to reduce the parts count and save space on your PCB - you only have to place one part instead of three.
You need a resistor in series with the base of the transistor to limit the current through the base.  Too much current could damage the transistor (if your microprocessor can deliver enough current.) Alternatively, it prevents damage to the microprocessor by limiting the current drawn from the processor pin.
The resistor from the base to ground is often left out.  It takes care of the case where there is no signal on the base.  It pulls the base to ground to make sure the transistor stays &quot;open&quot; (and the lamp off.)  The outputs of many processors is &quot;high impedance&quot; at power on - the output is neither high nor low, but rather &quot;floating.&quot;  In that condition, the base of the transistor could pick up enough stray current to turn on the lamp (or do other, worse things) when it shouldn't.  The resistor to ground prevents those undefined events from happening.