Hi,
there is a relationship between power dissipation and temparature_rise.
But there ar additional parameters that influence it: air, air flow, humidity, mounting direction and so on.
for a TO-220 you may find in the datasheet R_PJA about 65°C/W (junction - air)
**********
If you want to keep it at constant temperature you could do this with a regulation loop.
With a BJT V_BE changes with about -2mV/°C. you could use this effect to measure the BJT´s die temperature.
For higher precision you should switch between "heating" and "measuring". While heating base current changes. But allways use the same (constant) base current during measurement (1 ms may be sufficient)
Klaus