The scar was a link between Voldemort and Harry. It hurt Harry when Voldemort was angry, happy, etc. Because Voldemort died at the end, the link was broken and the scar didn't hurt anymore. It was proof that Voldemort was gone for good, so all was well.