The control and managing of power demand and supply become very crucial because of penetration of renewables in the electricity networks and energy demand increase in residential and commercial sectors. In this paper, a new approach is presented to bridge the gap between Demand-Side Management (DSM) and microgrid portfolio and placement optimization. Although DSM helps energy consumers to take advantage of recent developments in utilization of Distributed Energy Resources (DERs) especially microgrids, a huge need of connecting DSM results to microgrid optimization is being felt. Consequently, a novel model that integrates the DSM techniques and microgrid modules in a two-layer configuration is proposed. In the first layer, DSM is employed to minimize the electricity demand (e.g. heating and cooling loads) based on zone temperature set-point. Using the optimal load profile obtained from the first layer, all investment and operation costs of a microgrid are then optimized in the second layer. As a demonstration, the developed model has been used to study the impact of smart HVAC control on microgrid compared to traditional HVAC control. The results show a noticeable reduction in total annual energy consumption and annual cost of microgrid.