Demand side management encourages the users in a smart grid to shift their electricity consumption in response to varying electricity prices. In this paper, we propose a distributed framework for the demand response based on cost minimization. Each user in the system will find an optimal start time and operating mode for the appliances in response to the varying electricity prices. We model the cost function for each user and the constraints for the appliances. We then propose an approximate greedy iterative algorithm that can be employed by each user to schedule appliances. In the proposed algorithm, each user requires only the knowledge of the price of the electricity, which depends on the aggregated load of other users, instead of the load profiles of individual users. In order for the users to coordinate with each other, we introduce a penalty term in the cost function, which penalizes large changes in the scheduling between successive iterations. Numerical simulations show that our optimization method will result in lower cost for the consumers, lower generation costs for the utility companies, lower peak load, and lower load fluctuations.