Recently, power line communication (PLC) is receiving attention from academic and industry researchers worldwide. In particular, PLC systems have been largely investigated as a medium for transmitting control signals, diagnostic information, or data measured by sensors in Smart Grid. However, PLC systems face several challenges, such as multipath effects and impulsive noise, which may degrade data communication performance. To surpass such issues we propose CodePLC, a dynamic network coding MAC protocol for PLC. CodePLC relies on a single, yet dynamically chosen, relay node. This node stores and forwards linear combinations of PLC frames, which are then combined on their final destinations. We have evaluated the performance of CodePLC through simulations in a PLC system based on a time division multiple access orthogonal frequency-division multiplexing scheme. Simulation results indicate that, in broadcast transmissions, CodePLC enhances system performance. When compared to a PLC system that does not consider the use of CodePLC, based on a stop&wait MAC layer protocol, our new protocol presents an average of 115% of goodput increase. Moreover, CodePLC reduces the average network buffers occupancy by 112%. Finally, our protocol is capable of reducing the mean end-to-end latency by 400%.