A player gets to take a free throw when they are fouled while shooting or if the other team has had too many fouls. Teams are allowed up to four fouls per quarter before non-shooting fouls earn free throws. The amount of free throws a player takes depends on the number of points their shot was worth. If the player was fouled but still made their shot, they would only receive one extra free throw. The clock freezes during a free throw, but the player has about ten seconds to shoot.
So if a player was attempting a 3 pointer and was fouled, they would get 3 free throws.
The scoring settings for free throws are found under League Settings -> Scoring Settings.