A system of neutral atoms trapped in an optical lattice and dispersively coupled to the field of an optical cavity can realize a variation of the Bose-Hubbard model with infinite-range interactions. This model exhibits a first order quantum phase transition between a Mott insulator and a charge density wave, with spontaneous symmetry breaking between even and odd sites, as was recently observed experimentally [Landig et. al., Nature 532 (2016)]. In the present paper we approach the analysis of this transition using a variational model which allows us to establish the notion of an energy barrier separating the two phases. Using a discrete WKB method we then show that the local tunneling of atoms between adjacent sites lowers this energy barrier and hence facilitates the transition. Within our simplified description, we are thus able to increment the phase diagram of the model with information concerning the height of the barrier separating the metastable minima from the global minimum in each phase, which is an essential aspect for the understanding of the reconfiguration dynamics induced by a quench across a quantum critical point.