The constantly increasing of Renewable Energy Sources (RES) in modern distribution networks, such as Pho-tovoltaic Energy (PV) generation, brings new challenges in the planning and operation of distribution networks. In this context, the objective of this paper is to propose an optimization model considering an Multi-period Optimal Power Flow (MOPF) for optimal allocation and operation of Battery Energy Storage Systems (BESSs) with PV in modern distribution networks. The formulation was developed in Modeling Language for Mathematical Programming (AMPL) and solved using the Knitro solver in a time horizon of 24 hours, aiming to reduce energy losses. In addition to minimizing energy losses, an improvement in the voltage profile and a flat generation curve in the substation is verified. To show the applicability and effectiveness of the proposed model, several analyzes were performed on the 33-bus distribution test system. The results allow us to conclude that the proposed model for optimal allocation and management of BESS with RES is suitable for real-world applications, resulting in important reductions in energy losses and leveling of voltage profiles.