Calculating base resistor value
First you have to determine what the maximum collector current is that the transistor needs to support when on.

Divide this collector current by the gain of the transistor to get the minimum required base current.  The gain of a BJT varies with operating point, so you have to look at the datasheet carefully to see what gain value you can assume at your maximum collector current.

Once you know the minimum required base current, it's just a matter of Ohm's law to find the base resistance.  The B-E junction of the transistor looks like a diode to the driving circuit.  Figure it will drop around 700 mV when the base current is flowing.  Subtract that from the logic high level to find the voltage across the base resistor.  By Ohm's law, the resistance is the voltage divided by the current.

Remember that this calculation was based on the minimum required base current.  That means the result is the maximum allowed base resistance.  It's usually good to round down the resistance one or two standard values to leave some margin.

Now that you've picked a base resistance, work backwards to find the actual base current, and check to make sure the digital output can deliver that.  If not, that transistor in that circuit won't work.

That all said, why not use a FET?  It seems you only need to switch 12 V.  It looks like the IRLML2502, for example, would work nicely here.  Then you don't need a base resistor at all.  The on-state voltage drop will also be lower.