Per Writes...
How to calculate if you need a heatsink for a BJT
Calculating for the BJT requires you to know the voltage drop from Collect to Emitter. This can be tricky because it depends on whether or not the transistor is in saturation. That’s a function of how much current is flowing from the Base to the Emitter (the so-called “Transistor Effect.”) The amount of current flowing through the transistor (from collector to emitter) also changes the Vce.
Collector-Emitter Voltage
Assuming you use the transistor as a switch and you are saturating the transistor (turning it on completely), look for the “Collector-Emitter Saturation Voltage.”
On the popular 2n2222, if the base to emitter current ranges from 0.3V to 1.0V.
Power Dissipation
Assuming the worst case, let’s say it is a 1.0V drop. Using your load’s current, calculate the power the transistor is dissipating:
Power = Vce * I
2n2222 500mA Example
I’ll use 500mA for an example:
Power = 1.0V * 500mA = 500mW
Junction Temperature
Now you need to calculate how hot the silicon inside of the transistor will get, using the package’s thermal resistance.
Thermal Resistance (Tja)
For a TO-92 2n2222 that thermal-resistance (Tja) from Junction (the silicon) to Ambient (outside air) is 200°C / Watt.
This means for every 1 the transistor dissipates, the internal silicon will rise 200°C.
Power Dissipation (Pd)
In my example, our dissipated power (Pd) is 500mW (or 0.5 Watts). So the junction temperature will be:
Junction Rise = Pd * Tja = 0.5W * 200°C/W = 100°C.
But don’t forget, you need to add the ambient temperature, so for room temperature that is 25°C.
Junction Temp = Rise + Ambient = 100°C + 25°C = 125°C.
Maximum Junction Temperature
In this case, I’m looking at a 2n2222 from Fairchild which has “Max Junction Temperature” of 150°C.
So in this case, I would not need a heat sink. If we calculated a junction temperature greater than the maximum allowed junction, then we would need to re-calculate the heat rise. This would involved using the "Junction to Case" thermal resistance of the transistor PLUS the thermal resistance of the heat sink used.