A microgrid is a power distribution system that mixes distributed energy resources with controlled loads, and it has the capability to operate both grid-connected mode and islanding mode. However, increasing electricity demand and electricity cost remains a major problem worldwide. To mitigate these cost issues, several organizations have developed innovative techniques for power control, monitoring and security. The Energy Management System (EMS) focuses more on managing power between load and source sides. To overcome the aforementioned issues, an intelligent EMS controller is proposed in this paper. The proposed intelligent controlling system manages power flows as well as reduce electricity cost very effectively. The proposed method contains four steps of the operation such as system design, data gathering, design of intelligent controller and EMS. Dataset is created based on the behaviour of a single person and corresponding load activation for that period, which is used for implementation and performance validation of the proposed method. The proposed method is validated for two modes of operations, namely, grid-connected mode and islanding modes. In both modes, the proposed method offers cost-effective control of energy flow. MATLAB/Simulink software has been used to design the proposed method and test its performance. The proposed method provides better accuracy of 95%. Furthermore, the outcome of the proposed method is compared with other existing methods such as k-nearest neighbours (KNN) and Naive Bayes (NB). The result demonstrates that the ANN-based EMS can interface with various power sources and offer well performance for the task of energy management.