"He asked me why I did it and was dumbstruck for a second."
What I am trying to say is that he was dumbstruck for a second after asking me why I did this. But I see that there is a possibility of people interpreting this sentence as saying that why I did this and was dumbstruck for a second was the question he asked. So, is this a correct sentence and contains the meaning I am intending to have, or is it somehow just inevitably interpreted as the second meaning?
Searching around, I found a possible solution to this. Putting a comma seemed to be a good idea.
"He asked me why I did it, and was dumbstruck for a second."
Now, does it mean what I make it mean?