This paper describes an optimal power allocation scheme for orthogonal frequency division multiple access two-way relay networks with physical network coding. The aim is to enhance the achievable sum rate of the terminals for a constrained total transmit power. Convex optimization is used to derive a closed-form solution for the power allocation between the relay node and the two terminals. This reduces the variable dimensionality of the objective function for the power assignment problem among multiple carriers when the total transmit power is constrained. This solution is then used to derive the optimal power control scheme. This method reduces the implementation complexity compared with the traditional resource allocation scheme. Numerical and simulation results show that the approach achieves almost the optimal sum rate and outperforms the fixed power assignment method with less computational load in various scenarios.