Recently, an optimal dosing algorithm (OptiDose) was developed to compute the optimal drug doses for any pharmacometrics model for a given dosing scenario. In the present work, we enhance the OptiDose concept to compute optimal drug dosing with respect to both efficacy and safety targets. Usually, these are not of equal importance, but one is a top priority, that needs to be satisfied, whereas the other is a secondary target and should be achieved as good as possible without failing the top priority target. Mathematically, this leads to state-constrained optimal control problems. In this paper, we elaborate how to set up such problems and transform them into classical unconstrained optimal control problems which can be solved in NONMEM. Three different optimal dosing tasks illustrate the impact of the proposed enhanced OptiDose method.