Numerical modeling of two-phase flows in heterogeneous and fractured media is of great interest in petroleum reservoir engineering. The classical model for two-phase flows in porous media is not completely thermodynamically consistent since the energy reconstructed from the capillary pressure does not involve the ideal fluid energy of both phases and attraction effect between two phases. On the other hand, the saturation may be discontinuous in heterogeneous and fractured media, and thus the saturation gradient may be not well defined. Consequently, the classical phase-field models can not be applied due to the use of diffuse interfaces. In this paper, we propose a new thermodynamically consistent energy-based model for two-phase flows in heterogeneous and fractured media, which is free of the gradient energy. Meanwhile, the model inherits the key features of the traditional models of two-phase flows in porous media, including relative permeability, volumetric phase velocity and capillarity effect. To characterize the capillarity effect, a logarithmic energy potential is proposed as the free energy function, which is more realistic than the commonly used double well potential. The model combines with the discrete fracture model to describe two-phase flows in fractured media. The popularly used implicit pressure explicit saturation method is used to simulate the model. Finally, the experimental verification of the model and numerical simulation results are provided.