Every transistor has a current gain, usually \$\beta\$ or \$h_{fe}\$ in the datasheet. Typical values are on the order of 100. When the transistor is not saturated, then the base current and collector current are related by this factor:
$$ I_c = h_{fe} I_b $$
When the base current increases to the point where collector current can increase no more, the transistor is said to be saturated. The collector current can increase no more because it can't permit any more current -- the current is entirely limited by R1 in your diagram, and the voltage from emitter to collector is at a minimum.
When we design digital logic, we don't want to just barely saturate the transistors. We want to saturate them a lot. This provides some extra margin against variations in \$h_{fe}\$, and also takes into account that for higher frequencies (necessary for quick high/low transitions), \$h_{fe}\$ is effectively reduced.
Rule of thumb: in digital logic, design for a collector current 15 times greater than the base current.
So here, you've selected a collector resistor of 1kΩ. At saturation, the emitter-collector voltage is much less than the supply voltage, so we can estimate the collector current as:
$$ I_c = \frac{5\mathrm V}{1\mathrm k\Omega} = 5\mathrm{mA} $$
We want the base current to be 1/15th that (0.33mA), and the voltage across the base resistor will be the supply voltage, less about 0.65V from the base-emitter junction of Q1. So:
$$ R_2 = \frac{5\mathrm V - 0.65 \mathrm V}{0.33\mathrm{mA}} = 13 \mathrm k \Omega $$
Your selection of 10kΩ is close enough.
You can also scale the resistor values up, maintaining the ratio of base to collector current, but reducing the current overall. That reduces your power consumption, but also reduces the logic speed as the smaller currents are able to charge the parasitic capacitances less rapidly. This is a performance vs. power consumption trade-off that you get to make as the engineer.
The main purpose of the base resistor is to limit excessive current to the base. The BJT is a voltage controlled device and hence current is not the driving factor for switching. The base resistor needs to be large enough to prevent damage to the transistor, but should still allow sufficient current to ensure the transistor switches on and off as per the base voltages.
Not using a base resistor sometimes works, but it's a terrible practice and it's just asking for trouble. Relying on this mechanism runs the risk of burning out your I/O pin as well as damaging your transistor, so its recommended you use a base resistor. Without a resistor, you are placing 5V on a low impedance input (Base - Emitter), and asking the Atmega/Arduino pins to source a lot of current. Eventually, if not immediately, that is going to destroy your Atmega.
However, you do not need a base resistor if you operate the transistor in the common collector configuration sometimes called an emitter follower. This is because any current flowing through the emitter load cause the voltage on the emitter to rise to a point where it is 0.7V below the voltage on the base and prevent any further current flowing. This is a sort of negative feedback on the base current.
Best Answer
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.