This research proposes an efficient energy management system for standalone and grid-connected direct current (DC) distribution networks that consider photovoltaic (PV) generation sources. A complete nonlinear programming model is formulated to represent the efficient PV dispatch problem while taking three different objective functions into account. The first objective function corresponds to the minimization of the operational costs with respect to the energy purchasing costs at terminals of the substation, including the maintenance costs of the PV sources. The second objective function is the reduction of the expected daily energy losses regarding all resistive effects of the distribution lines. The third objective function concerns the minimization of the total emissions of CO2 into the atmosphere by the substation bus or its equivalent (diesel generator). These objective functions are minimized using a single-objective optimization approach through the application of the Salp Swarm Algorithm (SSA), which is combined with a matrix hourly power flow formulation that works by using a leader–follower operation scheme. Two test feeders composed of 27 and 33 nodes set for standalone and grid-connected operation are used in the numerical validations. The standalone grid corresponds to an adaptation of the generation and demand curves for the municipality of Capurganá, and the grid-connected system is adapted to the operating conditions in the metropolitan area of Medellín, i.e., a rural area and a major city in Colombia. A numerical comparison with three additional combinatorial optimizers (i.e., particle swarm optimization (PSO), the multiverse optimizer (MVO), and the crow search algorithm (CSA)) demonstrates the effectiveness and robustness of the proposed leader–follower optimization approach to the optimal management of PV generation sources in DC grids while considering different objective function indices.