Determination of the optimal well placement strategy in oil or gas fields is crucial for economic reservoir development. The optimization process, however, can be computationally intensive as a result of the potentially high-dimensional search space and the expensive numerical simulation. In this study, machine-learning-based surrogate models are constructed as efficient alternatives to numerical simulators to accelerate the optimization process. A V-Net neural network architecture is used with features of skip connections, 3D convolutional filters, and a residual learning structure to handle 3D parameter fields effectively. Physical guidance is incorporated into the neural network training process by adding governing equation constraints to the loss function in the discretized form, resulting in a physics-guided machine learning architecture: PgV-Net. Well placement optimization problems in a 3D oil-bearing formation with strong porosity and permeability heterogeneity are studied using the PgV-Net-based surrogate model along with genetic algorithms (GAs). Three optimization problems with increased complexity are solved, and the results are compared with regular approaches using a numerical simulator. Good agreement between the two approaches is observed, and the computational efficiency improves dramatically (up to 30 times). The proposed PgV-Net neural network training architecture reduces the requirement of expensive training data and can be used for more challenging problems such as multiphase flow modeling.