I think Dev is using reverse physcology to help Sona move ahead in life. Earlier he was stalking him but when Sona blasted him saying that she is trying to move on and it was him who decided to part ways, Dev realized his mistake.
Dev first did background check of Rithik to make sure he is a good person and his background is clean. He knows that he cannot have Sona and his life and Sona can never forgot him. So that's why he is telling to himself "Jab tak main tumse pyaar karta huin, tum aage kaise badh sakti ho". So he will try to portray himself as a bad person in front of Sonakshi and will do things that hurts her the most to help her forget him and move ahead with Rithik without any guilt.