In Gin Rummy, what happens when one knocks but the opposing player has a lower deadwood?
Your opponent Undercut you and scores usually 25 points plus the difference between your score and theirs (+2 in your case). Actually, unless you knockout on gin (zero points), if your opponent ties your score you are undercut. From pagat.com:


  If the knocker did not go gin, and the counts are equal, or the knocker's count is greater than that of the opponent, the knocker has been undercut. In this case the knocker's opponent scores the difference between the counts plus a 10 point bonus.