When to Localize? A Risk-Constrained Reinforcement Learning Approach