A balk is called when a pitcher deviates from his normal throwing motion or breaks a certain set of rules. Balks are only called when runners are on base because the penalty of a balk is the runners all advance one base.
Balks are typically called when a pitcher comes set, set meaning he has paused in his throwing motion just before he is set to deliver the pitch. Once a pitcher is set they can’t flinch, rotate their body sideways to look at the runner, etc. If they do a balk is called. If the pitcher hasn’t become set yet they can rotate and look over at the runner without penalty. A pitcher is usually not set when they are picking up the signs from the catcher.
A balk can also be called when a pitcher attempts to pickoff a runner but their front foot has crossed their back leg. This is more common when a left handed pitcher is on the mound. Lefty’s also try to deceive the runner by appearing to go to the plate but then throw over to first base. Their front foot will usually land somewhere between first base and home plate.