If you've forgotten what you said earlier, it's “What was I saying?”.
“What did I say?” has a completely different meaning. It is used when you notice the other person reacting in a strange way, and that question really means “You're reacting strangely, I think this is due to something I said, please explain to me which of my words caused you to react like this and why.” Sometimes the person asking this has genuinely forgotten what they said, but often they do remember but don't understand the reaction (or they're pretending not to).
If you've forgotten what the other person has said, you can ask “What were you saying earlier?” or “What did you say, again?” (or other variations). Neither sentence feels completely natural in this meaning without an adverb, though they aren't actually wrong.
“What did you say?” could also mean that you didn't understand what the person say, and with no other clues that's how I would understand it if I heard it.
— I think that [noise of an airplane going by]
— I'm sorry, what did you say?
When there is no apparent risk of interruption, it can also be a way to express surprise or disagreement with what was said.
— I don't like this painting.
— What did you say? That's my masterpiece! Why are you so unsupportive?
“What were you saying?” works best when there is some other context: “Whew, we got rid of the interruption. Now, what were you saying?” It can also have another meaning: when you've done something that changes the situation, and you think that what the person said no longer applies. It is common to shorten this to “You were saying?”.
— I don't like this painting.
[throws the painting away] — There. You were saying?
In situation 1, which version you select (they're both grammatically correct) depends on the tense in which you're telling the story. If you're telling the story in the present tense ("So I'm walking along the street..."), you would use option A to match, while if you're telling it in the past tense ("So I was walking along the street..."), you'd use option B.
In situation 2, you'll generally want either A or C.
The essence of the grammar article was probably that in English, it's possible to discuss either past events or hypothetical future events in the present tense, as if you were placing yourself in the time and narrating from that perspective. In this case, you'd use the present-tense "first time I've been", but it's much more common to narrate this way when relating past events than when talking about future plans.
Best Answer
Either is correct.
However, this is not usually what I say when I'm surprised. :-)