Yes, you can heat virgin coconut oil. Unlike other plant-based oils, it won't oxidize and break down easily into harmful compounds that are detrimental to your health. Thanks to the high content of saturated fats in virgin coconut oil.
However, its naturally-present polyphenols may greatly reduce especially when you use virgin coconut oil for deep frying. Polyphenols are sensitive to heat.
If you warm virgin coconut oil a bit for hair treatment, I think that's fine as the loss of its polyphenolic antioxidants is minimal.
Although it's best not to heat virgin coconut oil so that you can keep as much of its nutrients as possible for greater benefits, if you need to make it hot for good reasons, like using it in cooking, why not?
You're better off cooking with virgin coconut oil than those common vegetable oils which are so high in unsaturated fats that oxidize easily into toxic compounds. Agree?
But when virgin coconut oil is heated, make sure it doesn't smoke. If it smokes, all its nutritional and beneficial properties will collapse. It has a smoke point of about 350 °F (177 °C).