In an interdisciplinary field on mathematics and physics, we examine a physical problem, fluid flow in porous media, which is represented by a stochastic partial differential equation (SPDE). We first give a priori error estimates for the solutions to an optimization problem constrained by the physical model under lower regularity assumptions than the literature. We then use the concept of Galerkin finite element methods to establish a new numerical algorithm to give approximations for our stochastic optimal physical problem. Finally, we develop original computer programs based on the algorithm and use several numerical examples of various situations to see how well our solver works by comparing its outputs to the priori error estimates.