Is punishment of free riders driven by descriptive social norms of cooperation and punishment? We conduct experiments in which participants interact in a one-shot social dilemma with punishment. We study how punishment of free riders is influenced by behavior among members of a payoff-irrelevant reference group. Participants can condition punishment on either the level of cooperation or the level of punishment in the reference group, respectively reflecting descriptive norms of cooperation and punishment. We observe considerable heterogeneity in punishment behavior. Among punishers, the most common strategies are to increase punishment with higher levels of cooperation ("norm enforcement"), and to increase punishment with higher levels of punishment in the reference group ("conformist punishment"). By means of a simple dynamic model, we demonstrate that these conditional punishment strategies can substantially promote cooperation: conformist punishment helps cooperation to gain a foothold in a population, and norm enforcement helps to maintain cooperation at high levels. Our study illustrates how punishment is shaped by the social context, and highlights the potential of conditional punishment strategies to promote the emergence and maintenance of cooperation.