1.Play longer time controls.
Or
2.Move faster.
Play longer games. There is another way of looking it, you had a material\positional \kingsafety advantage (take your pick) and your opponent had a clock time advantage and proved it was superior by converting it to a win. My point is that maybe they outplayed you by converting their advantage. It is often forgotten that when you play fast chess, Clock Time becomes a strategic advantage so time management is much more important. You cant claim to be the stronger player but lose on time. Your opponent used their time differently and those choices were proved to be better than yours.
I had the same issue as the op when I started out and I also felt somewhat bad about winning on time. I'd still flag them if I could get a win from an otherwise losing position, but it always felt kind of like a "cheapo" concept. Then a chess.com forum thread about time control said something similar to this and the response from CM @JamesColeman stuck with me. Basically, it was said, "you were able to gain the advantage in the position likely because you used more time than the opponent to think. It is about time management: maybe the opponent wouldn't be in a worse position if they used more of their own time."
I don't feel as bad about flagging opponents anymore; I still don't usually feel good about it still, but that is why I seldom play really quick time controls. Both you and your opponent agreed to the time control, so flagging is part of the game. If they hate losing on time so much, then they could play with increment or a longer time control.
1.Play longer time controls.
Or
2.Move faster.
+1 In essence, this blunt answer is what it comes down to. You'll also get faster with experience/practice, so it might just take some more chess play/study. In the meantime, play longer time controls if this is a big enough issue; in fact, even when you get faster naturally - playing longer time controls is still not a bad idea
many many times ive totally outplayed my opponents only to lose on time .How can i rectify this problem my rating keeps on dropping