In this study, a lattice Boltzmann method (LBM) was employed to numerically investigate the effect of the heater location on entropy generation, flow pattern, and heat transfer in a cavity. The study was carried out for a heater of length 0.4H which is located at the lower wall of the cavity. The simulations were performed for Rayleigh numbers from 103 to 106 at Pr = 0.71. The results show that the location of the heater has a great effect on the flow pattern and temperature fields in the enclosure and subsequently on entropy generation. With increasing the distance between the heater and a cold wall the entropy generation decreases. On the other hand, a maximum Nusselt number is observed over the left cold wall when the heater is located near the cold wall. The slope variation (gradient) of the Nusselt number increases over the heater and the left wall of the cavity at a higher Rayleigh number for a fixed location of the heater. The dimensionless entropy generation decreases at a high Rayleigh number and is independent of the heater position.