Quantization of electromagnetic fields is investigated in the framework of stochastic variational method (SVM). Differently from the canonical quantization, this method does not require canonical form and quantization can be performed directly from the gauge invariant Lagrangian. The gauge condition is used to choose dynamically independent variables. We verify that, in the Coulomb gauge condition, SVM result is completely equivalent to the traditional result. On the other hand, in the Lorentz gauge condition, SVM quantization can be performed without introducing the indefinite metric. The temporal and longitudinal components of the gauge filed, then, behave as c-number functionals affected by quantum fluctuation through the interaction with charged matter fields. To see further the relation between SVM and the canonical quantization, we quantize the usual gauge Lagrangian with the Fermi term and argue a stochastic process with a negative second order correlation is introduced to reproduce the indefinite metric.