This paper develops an efficient and practical rule-based energy management system (EMS) for optimal planning of a residential microgrid under time-of-use (TOU) electricity rates to import/export powers from/to the main grid more economically. The developed EMS not only considers the renewable energy generation but also applies the electricity rates to manage power flow between the generation, storage, and consumption. The optimal capacity of wind turbine and battery energy storage are then determined by minimizing the cost of energy. The model includes battery degradation over its life and salvation value at the end of its lifetime. The actual annual load and weather data (at an interval of 1-hour) is carefully incorporated into the optimization model. The effectiveness of the developed model is then checked for a South Australian microgrid using real load and weather data profiles as well as TOU electricity rates. It is found that the proposed EMS and the optimal planning strategy can reduce the cost of electricity of the microgrid compared to the net metering scheme. In addition, the grid-connected households can use 6 kW of WT and 3 kWh of BESS as the optimal capacities to achieve the minimum COE.