install heatsink on BJT
If I was faced with the problem that you have I would made modifications to the case design. The worst case 400mW is hard to get out of the fully plastic case. On the other hand that power level is not too bad if you could get the heat flow to the outside.

I would made the case in such a way that it has one of:


A metal cup base
A side metal band all the way around
A metal disk bottom 


One of these approaches can be leveraged to act as a heatsink for the heat generating transistor. Of course you will want to do this in a way that the metal heatsink piece is full isolated electrically from the rest of the circuit.