What happens if I have only the 8 (black) ball left to pot and my opponent who has a colored ball scratches the cue ball? Do I get a ball in hand or do I have to try potting the black ball from behind 'the line'?
It depends what rules you play by. By Official pool rules, you would have ball in hand as they committed a foul.
3.9 Standard Fouls
If the shooter commits a foul, play passes to his opponent. The cue ball is in hand, and the incoming player may place it anywhere on the playing surface.
On the Foul:
The following actions are fouls at pool when included in the specific rules of the game being played. If several fouls occur on one shot, only the most serious one is enforced. If a foul is not called before the next shot begins, the foul is assumed not to have happened.
Cue Ball Scratch or off the Table If the cue ball is pocketed or driven off the table, the shot is a foul.
However, it depends what rules you play by, determined prior to the match start.
When the cue ball is in hand, the shooter may place the cue ball anywhere on the playing surfaceand may continue to move the cue ball until he executes a shot. Players may use any part of the cue stick to move the cue ball, including the tip, but not with a forward stroke motion. In some games and for most break shots, placement of the cue ball may be restricted to the area behind the head string depending on the rules of the game, and then 6.10 Bad Cue Ball Placement and 6.11 Bad Play from Behind the Head String may apply.
For reference, behind the head string is also known as the kitchen.
I would recommend clarifying with your opponent which rules you want to play by prior to starting the game. [I usually play any foul committed is ball in hand]
As @ZeroStack points out it depends on the rules you are playing. If you are playing IPA Backball Rules, you can have cue ball in hand anytime your opponent commits a foul.
Rule 4h states that when you have cue ball in hand, you must play anywhere behind the baulk line.