The small DC motor, is likely to use more power than an digital output can handle directly. The transistor has three leads. Most of the electricity flows from the Collector to the Emitter, but this will only happen if a small amount is flowing into the Base connection.
eBay