A real-time polymerase chain reaction (PCR)-based method for the detection of the walnut (Juglans regia) component in food is described here. The method consists of DNA isolation by chaotropic solid phase extraction and the subsequent PCR with walnut-specific primers and a TaqMan fluorescent probe. The primers and the probe are targeted to the jug r2, a major allergen gene of walnut. The method was positive for 8 varieties of walnut and negative for all other tested plant materials used in food industry, including pecan nuts. The intrinsic detection limit of the method was 0.24 ng walnut DNA. Using a series of model pastry samples with defined walnut contents, a practical detection limit of 0.01% walnut content was estimated. Practical applicability of the PCR method was tested by the analysis of 13 food samples (bakery and confectionery products), out of which two cakes were found to contain walnuts although they were not adequately labelled. The presented PCR method is useful for sensitive and selective detection of walnuts in food samples and can be performed in one working day.