Context. The formation of water on the dust grains in the interstellar medium may proceed with hydrogen peroxide (H2O2) as an intermediate. Recently gas-phase H2O2 has been detected in {rho} Oph A with an abundance of ~1E-10 relative to H2. Aims. We aim to reproduce the observed abundance of H2O2 and other species detected in {rho} Oph A quantitatively. Methods. We make use of a chemical network which includes gas phase reactions as well as processes on the grains; desorption from the grain surface through chemical reaction is also included. We run the model for a range of physical parameters. Results. The abundance of H2O2 can be best reproduced at ~6E5 yr, which is close to the dynamical age of {rho} Oph A. The abundances of other species such as H2CO, CH3OH, and O2 can be reasonably reproduced also at this time. In the early time the gas-phase abundance of H2O2 can be much higher than the current detected value. We predict a gas phase abundance of O2H at the same order of magnitude as H2O2, and an abundance of the order 1E-8 for gas phase water in {rho} Oph A. A few other species of interest are also discussed. Conclusions. We demonstrate that H2O2 can be produced on the dust grains and released into the gas phase through non-thermal desorption via surface exothermic reactions. The H2O2 molecule on the grain is an important intermediate in the formation of water. The fact that H2O2 is over-produced in the gas phase for a range of physical conditions suggests that its destruction channel in the current gas phase network may be incomplete.