In software-defined networking (SDN), OpenFlow switches typically utilize ternary content addressable memory (TCAM) to store flow tables for fast wildcarding lookups. In order to promote packet forwarding performance, it usually requires enlarging TCAM capacity to store more entries. However, TCAM performs lookups in parallel matching, which brings about high energy consumption. Therefore, it is necessary to choose the appropriate TCAM capacity to balance the delay and energy consumption of packet forwarding. For the typical scenario of software-defined data center network (SD-DCN), we characterize the packet processing of an OpenFlow switch as a multi-priority M/G/1 queueing model, and build an OpenFlow-based packet forwarding delay model. Meanwhile, we establish a hit rate model of TCAM flow tables based on flow distribution characteristics, to solve the relational expression between packet forwarding delay and TCAM capacity. Considering the energy consumption of TCAM lookups, we establish a joint optimization model of energy consumption and efficiency regarding packet forwarding, and design an optimization algorithm to solve the optimal TCAM capacity. The experimental results indicate that our proposed delay model can more accurately characterize OpenFlow-based packet forwarding delay than existing models do. Meanwhile, we leverage the optimization algorithm to solve the optimal TCAM capacity with different parameter configurations, which provides a guideline for actual SD-DCN deployments.