Physical activity and a healthy, balanced diet are remaining unresolved issues among young people. According to the World Health Organization, young people do not get enough exercise during the week, and physical education classes are the best way to promote healthy habits. This study aims to analyze how the role of the teacher influences the frustration of psychological needs, coping strategies, motivation, and the adoption of healthy eating habits through the Mediterranean diet and the regular practice of physical activity. The study involved 1031 boys and 910 girls between the ages of 13 and 18. To explain the relationships between the different variables included in this study, a model of structural equations has been developed. The results showed that autonomy support negatively predicted the frustration of four psychological needs. The failure to meet four psychological needs negatively predicted resilience. Likewise, resilience positively predicted autonomous motivation, and this positively predicted the Mediterranean diet and the practice of physical activity. Thus, the results obtained in the present study are in line with those of various studies wherein physical education classes were seen to help consolidate healthy living habits