In general they won't know about the transaction until you tell them.
There may, of course, be a department within HMRC tasked with trawling around for such transactions, though it is hard to see how they can separate off those selling land which form their principal private residence (and are not liable to CGT anyway). These will be the vast majority of the land transactions informed to the Land Registry, but you never know what 'investigations' HMRC revenue-chasers are undertaking.
Ignorance of the law is no defence in the event of being caught much later, of course.