Chandrashekhara Ashtakam is believed to be created by Sage Marakandeya. It is believed that when Yama is trying to take life of Sage Marakandeya, then he had sung this Stotram and thus Lord Shiva has saved him.
I have read this story in Padma Purana, Uttara Khanda downloaded from vedpuran.net website. But this story is not found in any other version of Padma Purana. So, I think the Padma Purana which I have is interpolated. That's why I am looking for the source of Chandrashekhara Ashtakam.