In this paper, to jointly study the energy dynamic behavior of humans and the corresponding physical dynamics of the microgrid, we bridge two disciplines: systems & control and environmental psychology. Firstly, we develop second order motivation-behavior mathematical models inspired by opinion dynamics models for describing and predicting human activities related to the use of energy, where psychological variables and social interactions are considered. Secondly, based on these models, we develop a human-cyber-physical system framework consisting of three layers: (i) human, (ii) cyber and (iii) physical. The first one describes human behavior influenced by behavioral intervention and motivation, which in turn depend on contextual factors, personal values and social norms. The cyber layer solves an optimization problem and embeds load controllers, which are designed to automatically mimic human behavior. Finally, the physical layer represents an AC microgrid. Thus, we formulate a social-physical welfare optimization problem and solve it by designing a distributed primal-dual control scheme, which generates the optimal behavioral intervention (with respect to a given reference) and the control inputs to the microgrid.