The problem of particle loading in particle-in-cell gyrokinetic simulations is addressed using a quadratic optimization algorithm. Optimized loading in configuration space dramatically reduces the short-wavelength modes in the electrostatic potential that are partly responsible for the nonconservation of total energy; further, the long-wavelength modes are resolved with good accuracy. As a result, the conservation of energy for the optimized loading is much better that the conservation of energy for the random loading. The method is valid for any geometry and can be coupled to optimization algorithms in velocity space. PACS Nos.: 52.35.Py, 52.30.Jb, 52.55.Fa