Today’s need for fuel efficient vehicles, together with increasing engine component complexity, makes optimal control a valuable tool for the process of finding the most fuel efficient control strategies. To efficiently calculate the solution to optimal control problems a gradient based optimization technique is desirable. However, this requires that the model is continuously differentiable. Many existing control-oriented Diesel engine models do not have this property, often due to signal saturations or discrete conditions. This paper offers a continuously differentiable, mean value engine model, of a heavy-duty diesel engine equipped with VGT and EGR, suitable for optimal control purposes. The model is developed from an existing, validated, engine model, but adapted to be continuously differentiable and therefor tailored for usage in an optimal control environment. The adaption is made by, among other things, removing the discrete switching functions and replacing them with differentiable switching functions, based on hyperbolic tangent. The changes due to the conversion is quantified and presented. Furthermore, it is shown how modern simulation and optimal control tools can be used to find the optimal control using the model, during both stationary and dynamic conditions. For the stationary conditions, the optimal control is calculated for the complete engine envelope using simulation techniques. For the dynamic conditions, tip-ins and tip-outs are studied, revealing, non-trivial, optimal actuation of fuel injection, VGT, and EGR.