In history class he saw a photo of Khan who took over the world in the '90s. He'd heard something about him being frozen, revived, and then banished to a planet, so even though he wasn't on the Enterprise during Space Seed, he put 2 and 2 together and realized whom it was.
He read the Enterprise manuals which had all the members of Star Fleet, even ones like Chekov who were not yet on the ship. Also he liked Three Sisters as well as Paradise Lost.
Years ago on the convention circuit, Walter Koenig had his own explanation that Khan was waiting to use a small restroom and Chekov (who hadn't been on TV yet) was in there for too long, leaving Khan waiting to use the restroom. They exchanged words briefly when Chekov finally got out.
Khan, being very thorough in the Enterprise tech manuals, also was thorough in looking through the crew manifest to see who he would be fighting, particularly the bridge officers.
We didn't see Khan meet Chekov but it doesn't mean it didn't happen off screen. Though Chekov wasn't part of the regular bridge crew at that time doesn't mean he wasn't working elsewhere on the ship.
We also don't see anyone go to the toilet on Star Trek, but that doesn't mean people in the 23rd century don't need to go to the toilet.
I remember hearing an old fan joke that combines these... Khan was waiting to use the toilet but Chekov was in there taking forever. Being the vengeful sort, Khan would never forget the face of the guy who made him wait so long.