A lot of mental and physical skills are heritable (IQ, for one).
If you accept a logical conclusion that over the course of history people who possessed a great deal of skills useful in a profession gravitated towards a profession where those skills would be utilized more effectively, then their children would likely possess the same traits (it's not 100% guaranteed - that's not what heritability means).
Examples of heritable skills:
Facial recognition (e.g. law enforcement)
Overall IQ (heritability 0.7-0.8 - source: Plomin, R.; Pedersen, N. L.; Lichtenstein, P.; McClearn, G. E. (1994). "Variability and stability in cognitive abilities are largely genetic later in life". Behavior Genetics 24 (3): 207–15. doi:10.1007/BF01067188. PMID 7945151. and a bunch of others linked on Wiki ).
This means that professions requiring higher IQ (engineers, masons, war chiefs) would be included.
Autism (A list of references is on Wiki, I will copy/paste one later when I have more time or hope someone copy/pastes them in the interim). Autism spectrum disorders (especially Aspergers) are heritable AND highly correlated with geek professions.
Again, engineers, monks, scribes, lawyers, alchemists/philosophers/scientists, etc...
Physical skills (both mental such as reaction time, spacial orientation etc... and purely physical - endurance, strength) - [citation needed]
E.g. sailors would need good spacial orientation and balance, and high tolerance for bad rum.
Please note that not all professions are the same skill-wise, and not all skills are equally heritable.
Farming (one of your examples) doesn't exactly require much in the way of heritable skills (though it requires learned ones).