Exodus 1:11 - "Therefore they set taskmasters over them to afflict them with heavy burdens; and they built for Pharaoh store cities, Pithom and Raamses."
Just as today we have foremen who assign jobs and see that their instructions are carried out, the ancient rulers also had such foremen, and they were called taskmasters. However, whereas today we hardly expect the plant foreman to be a cruel person, whose job is in enforcing his orders by physical means, this is exactly what the ancient taskmaster embodied. In fact, the Egyptian taskmasters were equipped with rods for disciplinary purposes, and their cruelty is legendary. To carry out the idea even further - the Hebrew root of the word means "to oppress." So you can see that they were hard men to deal with, indeed, and hardly wise to cross.
Pharaoh had appointed these taskmasters over the Hebrews to make their work hard and wearisome; he hoped by such oppression to break down their physical strength, and thereby to reduce their numerical growth, and also to crush their hopes of ever regaining their liberty.
With such men in their ancestral background, we can understand why the fact that David and Solomon had such men in their administrations was disruptive. This was one of the complaints made to Rehoboam - his father Solomon’s forced-labor system was bitterly resented.
In the writings of the prophets, any foreign ruler or oppressor may be given this title, as is also the driver of an animal. The simile is apt - as the driver forces his beast to go the way he wishes by the use of the whip, so also the taskmaster forces the people under him to do what he wishes by the use of force.