One assignment for my Japanese class is this Japanese elementary reader, which contains the story of Kenta and his dog, Koro. They are playing catch with a ball, and the previous sentence I translated as:
In the field, whenever Kenta throws the ball, Koro happily runs and catches it.
Now, the sentence in question is the next one:
I get the basic idea on how to break this down:
何回目か is the amount of times in a sequential order, made as a question clause with か; this entire clause is targeted by the verb [clause] with に.
ボールを投げた時のことです is "when the ball is thrown [general event]." The last part makes the "when" clause a relative clause able to be ended with a state-of-being (です). the former portion is just a clause using when with とき.
However, the use of 何回目かに confuses me, as I have not a clue how to relate it to the second part of the sentence. How should I understand its usage? Why is the 目 relevant to add? How should I comprehend the sentence as a whole, since 何回目か is the target, and an important part of the sentence?