This article presents a distributed periodic event-triggered (PET) optimal control scheme to achieve generation cost minimization and average bus voltage regulation in DC microgrids. In order to accommodate the generation constraints of the distributed generators (DGs), a virtual incremental cost is firstly designed, based on which an optimality condition is derived to facilitate the control design. To meet the discrete-time (DT) nature of modern control systems, the optimal controller is directly developed in the DT domain. Afterward, to reduce the communication requirement among the controllers, a distributed event-triggered mechanism is introduced for the DT optimal controller. The event-triggered condition is detected periodically and therefore naturally avoids the Zeno phenomenon. The closed-loop system stability is proved by the Lyapunov synthesis for switched systems. The generation cost minimization and average bus voltage regulation are obtained at the equilibrium point. Finally, switch-level microgrid simulations validate the performance of the proposed optimal controller.