The large-scale deployment of distributed energy resources will produce reverse power flows, voltage, and congestion problems in the distribution networks. This paper proposes a novel optimization model to support distribution system operators planning future medium voltage distribution networks characterized by high penetration of behind-the-meter distributed energy resources. The optimization model defines the optimal mix, placement, and size of on-load tap charger transformers and energy storage devices with the objectives of mitigating network technical problems and minimizing both investment and operation costs. The proposed optimization model relaxes the non-convex formulation of the optimal power flow to a constrained second-order cone programming model and exactly linearizes the non-linear model of the on-load tap changer transformer via binary expansion scheme and big-M method. These two transformations reduce the computational burden of the optimization allowing it to be applicable to real-scale distribution grids, as demonstrated by the results. The numerical results also show that the joint optimization of energy storage devices and on-load tap changer transformers produces a more affordable and flexible planning strategy than the individual optimization of the technologies.