"John, I think you should know that I consider myself married to my work, and while I’m flattered by your interest, I’m really not looking for any kind of…"
Sherlock was flattered. Not only did he think that John was interested in him, he didnt shoot him down right away. He told John he was flattered, and then politely declined.
However, he couldn’t catch a simple hint—Molly putting on lipstick for him or asking him for coffee. He thought John was interested and nicely rejected him, despite the fact that John had no interest whatsoever. Yet when it was clear that Molly had feelings for him, Sherlock was oblivious. It wasn’t until he had gone too far that he felt bad. With John, Sherlock hadn’t insulted him, or the idea of John being with someone. When it came to Molly, he called her out for trying too hard, and still didn’t get the hint.
It’s interesting that Sherlock was so civil about declining a nonexistent offer from John, when he was his usual sociopathic self when it came to Molly. He wasn’t in tune with her feelings or her intentions until it was too late.
It’s almost as though he was paying more attention to John. John had somehow broken through the barrier that caused Sherlock to say what he wanted when he wanted, without thinking of the interests of other people. John caused Sherlock to think differently, acting as a more intuitive person would, acknowledging the fact that romantic interest is quite like a compliment. However when it came to Molly, someone that had never really gotten through to Sherlock, he was his normal self. Talking before he thought it through, and putting himself before others. Yes, he clearly felt bad after Molly pointed out that he always said such horrible things, but it took Molly highlighting that fact for him, while with John he was able to understand what an acceptable response would be without having it pointed out to him.