With the assumption that the optical variability timescale is dominated by the cooling time of the synchrotron process for BL Lac objects, we estimate time dependent magnetic field strength of the emission region for two BL Lac objects. The average magnetic field strengths are consistent with those estimated from core shift measurement and spectral energy distribution modelling. Variation of magnetic field strength in dissipation region is discovered. Variability of flux and magnetic field strength show no clear correlation, which indicates the variation of magnetic field is not the dominant reason of variability origin. The evolution of magnetic field strength can provide another approach to constrain the energy dissipation mechanism in jet.