It seems that you're adding the click event to the div, but the close-icon class resides on the span inside the div.
Try the following:
$(".heading").click(function(){
$(this).next("div").slideToggle(500);
$(this).find('span').toggleClass("close-icon open-icon");
});