Depending on the type of electric fireplace you choose, it is perfectly safe to install an electric fireplace under a TV. In most cases, you can place electronics above your electric fireplace with no adverse effects, although you should be careful with wall-mounted fireplaces that push out heat through the top of the unit.
We generally recommend choosing an electric fireplace mantel if you want to keep electronics above your fireplace. These products can be designed with storage space to seamlessly fit both the TV and the firebox into your living space.