When Harry ran into Malfoy in the bathroom, Malfoy had tried to use an unforgivable curse on him, Malfoy had tried to use Avada Kedavra. Harry used the only curse that he could think of in that moment which happened to be sectumsempra because of his association with enemies and Draco being his biggest enemy. Later, when Hermione confirms that whoever the Half Blood Prince was, he was no doubt a bad person because of this curse, Ron countered that it was a good thing Harry Potter knew about the curse because otherwise he would be dead.