This paper presents a modeling and optimization framework to minimize the energy consumption of a fully electric powertrain by optimizing its design and control strategies whilst explicitly accounting for the thermal behavior of the Electric Motor (EM). Specifically, we first derive convex models of the powertrain components, including the battery, the EM, the transmission and a Lumped Parameter Thermal Network (LPTN) capturing the thermal dynamics of the EM. Second, we frame the optimal control problem in time domain, and devise a two-step algorithm to accelerate convergence and efficiently solve the resulting convex problem via nonlinear programming. Subsequently, we present a case study for a compact family car, optimize its transmission design and operation jointly with the regenerative braking and EM cooling control strategies for different motors and transmission technologies. We validate our proposed models using the high-fidelity simulation software Motor-CAD, showing that the LPTN quite accurately captures the thermal dynamics of the EM, and that the permanent magnets' temperature is the limiting factor during extended driving. Furthermore, our results reveal that powertrains equipped with a continuously variable transmission (CVT) result into a lower energy consumption than with a fixed-gear transmission (FGT), as a CVT can lower the EM losses, resulting in lower EM temperatures. Finally, our results emphasize the significance of considering the thermal behavior when designing an EM and the potential offered by CVTs in terms of downsizing.