Purpose: Fluence-modulated proton computed tomography (FMpCT) using pencil beam scanning aims at achieving task-specific image noise distributions by modulating the imaging proton fluence spot-by-spot based on an object-specific noise model. In this work, we present a method for fluence field optimization and investigate its performance in dose reduction for various phantoms and image variance targets. Methods: The proposed method uses Monte Carlo simulations of a proton CT (pCT) prototype scanner to estimate expected variance levels at uniform fluence. Using an iterative approach, we calculate a stack of target variance projections that are required to achieve the prescribed image variance, assuming a reconstruction using filtered backprojection. By fitting a pencil beam model to the ratio of uniform fluence variance and target variance, relative weights for each pencil beam can be calculated. The quality of the resulting fluence modulations is evaluated by scoring imaging doses and comparing them to those at uniform fluence, as well as evaluating conformity of the achieved variance with the prescription. For three different phantoms, we prescribed constant image variance as well as two regions-of-interest (ROI) imaging tasks with inhomogeneous image variance. The shape of the ROIs followed typical beam profiles for proton therapy. Results: Prescription of constant image variance resulted in a dose reduction of 8.9% for a homogeneous water phantom compared to a uniform fluence scan at equal peak variance level. For a more heterogeneous head phantom, dose reduction increased to 16.0% for the same task. Prescribing two different ROIs resulted in dose reductions between 25.7% and 40.5% outside of the ROI at equal peak variance levels inside the ROI. Imaging doses inside the ROI were increased by 9.2% to 19.2% compared to the uniform fluence scan, but can be neglected assuming that the ROI agrees with the therapeutic dose region. Agreement of resulting variance maps with the prescriptions was satisfactory. Conclusions: We developed a method for fluence field optimization based on a noise model for a real scanner used in pCT. We demonstrated that it can achieve prescribed image variance targets. A uniform fluence field was shown not to be dose optimal and dose reductions achievable with the proposed method for FMpCT were considerable, opening an interesting perspective for image guidance and adaptive therapy.