"It only hurts when I laugh" is a punchline of a joke which exists in numerous versions since at least 19th century. A typical setup is that someone badly hurt is asked "Does it hurt?" - "I'm fine. It only hurts when I laugh."[1] [2]
The phrase has been used as a title of various works: