In Pandemic, when does the discard-over-7-cards rule take effect?
First, note that the hand limit is 7 cards, NOT 8 cards!

You cannot hold more than 7 cards in your hand for any length of time. This means that while you are holding 7 cards, the researcher cannot give you 2 cards. Actions are one at a time, so first the researcher would give you a card, at which point you would be over the limit. Before any other action is taken, you must discard down to the hand limit. Once you are at 7 again, the researcher can give you another card now, at which point you will need to discard again.

You can play special event cards instead of discarding, however. So the answer to your question is that you need to play/discard your excess cards immediately, before any other action is taken.

From the rules:


  If you ever have more than 7 cards in hand (after first resolving any 
  Epidemic cards you may have drawn), discard cards or play Event cards 
  until you have 7 cards in hand (see Event Cards on page 7).


and under the Share Knowledge action details:


  If the player who gets the card now has more than 7 cards, that player must 
  immediately discard a card or play an Event card (see Event Cards on page 7).