An optimal power flow algorithm for unbalanced three-phase distribution grids is presented in this paper as a new tool for grid planning on low voltage level. As additional equipment like electric vehicles, heat pumps or solar power systems can sometimes cause unbalanced power flows, existing algorithms have to be adapted. In comparison to algorithms considering balanced power flows, the presented algorithm uses a complete model of a three-phase four-wire low voltage grid. Additionally, a constraint for the voltage unbalance in the grid is introduced. The algorithm can be used to optimize the operation of energy storage systems in unbalanced systems. The used grid model, constraints, objective function and solver are explained in detail. A validation of the algorithm using a commercial tool is done. Additionally, three exemplary optimizations are performed to show possible applications for this tool.