Today’s need for fuel efficient vehicles, together with increasing engine component complexity, makes optimal control a valuable tool in 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, making continuously differentiable models preferable. Many existing control-oriented Diesel engine models do not fully posses 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 therefore tailored for usage in an optimal control environment. The changes due to the conversion are quantified and presented. Furthermore, it is shown and analyzed how to optimally control the engine in a fuel optimal way under steady-state conditions, and in a time optimal way in a tip-in scenario.