I too faced such a same problem with a Dell laptop. It's due to motherboard issues, this is due to Earth connection issue. circuit board gets affected is the root cause of this issue. Actually, I used to charge laptop through on extension box, instead of direct plug point connection. by that time itself. While touch inching laptop motherboard fan(back side)by keeping in hand I felt current passing(earth connection issues). but I didn't consider that much. at last motherboard hot crashed due that extension box(no proper circuit connection within that extension box). I found this after getting new laptop only. So, keep your charging plug point in safe way and use. In your case, either HP service center needs to find solution or try to change your laptop/motherboard.
Note: I don't know how many years you are using that laptop. Due to long usage it might not be working properly. On your laptop keep the fan(motherboard) side free and check its activity after 15 mins by pressing F1(function key) . in screen ,if you found any warning error. you have to change your motherboard. else you can work on free.
Is this a good answer ?