Eight-ball
It depends on the ruleset being used. The English Pool Association says it is a Loss Of Frame foul:
Loss of Frame Fouls
...
- Any deliberate attempt to prevent the opponent from potting the Eight Ball, when the opponent is on the Eight Ball, by way of a Serious Foul or other unsporting manoeuvre.
However, the World Pool Billiards Association says it may only be a Standard Foul, which is penalised by the opponent receiving ball in hand anywhere on the table.
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. (See 1.5 Cue Ball in Hand.)
The following are standard fouls at eight ball:
...
6.2 Wrong Ball First The first ball contacted by the cue ball on each shot must belong to the shooter’s group, except when the table is open.
Blackball
This is a Loss Of Rack foul. The World Pool Billiards Association says
5.14 Loss of Rack Fouls
The player loses the rack if he:
...
(c) intentionally violates 6.2 Wrong Ball First; or
(d) does not attempt to hit a ball on.
Again however, you may be playing to other rulesets, and this should be clarified in them.