Wildfires can severely damage electricity grids leading to long periods of power interruption. Climate change will exacerbate this threat by increasing the frequency of dry weather conditions. Under these climate conditions, human-related actions that initiate wildfires should be avoided, including those induced by power systems operation. In this paper, we propose a novel optimization model that is capable of determining appropriate network topology changes (via switching actions) to alleviate the levels of power flows through vulnerable parts of the grid so as to decrease the probability of wildfire ignition. Within this framework, the proposed model captures the relationship between failure probabilities and line-flow decisions by explicitly considering the former as a function of the latter. The resulting formulation is a two-stage model with endogenous decision-dependent probabilities, where the first stage determines the optimal switching actions and the second stage evaluates the worst-case expected operation cost. We propose an exact iterative method to deal with this intricate problem and the methodology is illustrated with a 54-bus and a 138-bus distribution system.