If you are shooting for the 8 ball and incidentally pocket an opponent's ball (having committed no other fouls), your inning simply comes to an end, and play passes to the opponent.
The opponent's ball remains in the pocket, and the opponent plays from where the cue ball came to rest (and not with "ball-in-hand", since no foul occurred).
You have met all of the requirements of a legal shot (called the ball and the pocket, and the cue ball hit your ball first). There is nothing special in this scenario based on the fact that you were shooting the 8 ball.
Here are the World Pool-Billiard association rules that apply (emphasis ours, for clarity).
8 Ball is a "call shot" game, thus, WPA rules for 8 ball reference definition 1.6 Standard Call Shot. This section tells us several things:
- The player only needs to call one of their object balls and it's intended target pocket.
- Extra detail, such as "other balls contacted or pocketed are irrelevant".
1.6 Standard Call Shot
In games in which the shooter is required to call shots, the intended ball and pocket must be indicated for each shot if they are not obvious. Details of the shot, such as cushions struck or other balls contacted or pocketed are irrelevant. Only one ball may be called on each shot.
Section 3.7, Spotting Balls, tells us that incidentally pocketed object balls are never spotted back on the table.
3.7 Spotting Balls (8 Ball)
If the eight ball is pocketed or driven off the table on the break, it will be spotted or the balls will be re-racked. (See 3.3 Break Shot and 1.4 Spotting Balls.) No other object ball is ever spotted.