Epistatic variance can be an important source of variation for complex traits. However, detecting epistatic effects is difficult primarily due to insufficient sample sizes and lack of robust statistical methods. In this paper, we develop a Bayesian method to map multiple quantitative trait loci (QTLs) with epistatic effects. The method can map QTLs in complicated mating designs derived from the cross of two inbred lines. In addition to mapping QTLs for quantitative traits, the proposed method can even map genes underlying binary traits such as disease susceptibility using the threshold model. The parameters of interest are various QTL effects, including additive, dominance and epistatic effects of QTLs, the locations of identified QTLs and even the number of QTLs. When the number of QTLs is treated as an unknown parameter, the dimension of the model becomes a variable. This requires the reversible jump Markov chain Monte Carlo algorithm. The utility of the proposed method is demonstrated through analysis of simulation data.