The saturation occurs when the beta (collector current to base current ratio) comes out of play.
One practical way I've been using for years is to select the collector-current-to-base-current ratio as "one tenth of the minimum datasheet-specified beta". From transistor to transistor this can vary a lot but for small signal transistors and low currents (e.g. less than 500 mA) something between 10 to 20 should be alright.
![transistor characteristics from datasheet](https://cdn.statically.io/img/i.sstatic.net/m9wT8.png)
(Image source: OnSemi P2N2222A datasheet)
For your case (20 mA), the beta seems to be somewhere between 75 and 100. To saturate, I'll select a ratio of 7.5:
![schematic](https://cdn.statically.io/img/i.sstatic.net/CcV5s.png)
simulate this circuit – Schematic created using CircuitLab
$$
\mathrm{I_B = I_C / 7.5 = 2.7 mA \\
R_B = (V_G - 0.7)/I_B}
$$
VG here is the output voltage of GPIO when it's outputting logic-1. So, for 4.5V, the base resistor can be 1k5. For 3.3V, it'll be 1k.
If turning on and off is the main purpose then you can use an NMOS such as 2N7000 (or 7002). Even without a resistor (normally you'll require one but let's ignore) you can use it as a switch.