Omega,
WHEN
The Bible is silent on this question but that has not stopped men from speculating. Jews at some point thought/believed it happened as the newly born breathed its first. This is probably due to the words spirit and breath being synonyms or etymologically related. vooke places it earlier in the pregnancy and MY reasons are thus;
1. There are several verses which point to God's active hand during the pregnancy such as Psalms 139:2, Jeremiah 1:5
2. In Exodus 21:22-25, inducing a miscarriage in a pregnant woman maliciously or not attracted massive penalties up to death. So the unborn are treated as humans and this would only make sense if indeed they are human (spirit and body)
3. In Ecclesiastes, we know the spirit departs the body on death. This means the body is incapable of life without the spirit. Since th unborn are clearly alive and kicking, I don't see how they can do that without the spirit
WHERE WAS THE SPIRITS BEFORE BEING PUT INTO MAN
This is a leading question. It presumes they was somewhere WITHOUT scriptural backing. An unscriptural question that then pretends to respect scriptures is a contradiction. What if God creates them and plants them in the womb?
I favor this over pre-existing human spirits, an idea embraced by Mormons. Again, here are my reasons;
1. Ecclesiastes 12 is clear that upon death, the spirit returns to God who gave it. So I know the human spirit comes from God. This is more or less what God breathing into man in Genesis is saying; God is the source. Now, in Jeremiah 1, God tells him that He KNEW him BEFORE he was born....the word KNOW would be out of place if Jeremiah was with God before he was born...it should read, 'I was WITH you before I formed you'. Doesn't make much sense
2. Angels are spirits and they fell into sin. So human spirits are equally capable of sinning. In Revelation and elsewhere in the scriptures, the ONLY judgement we read of is of men and angels. Heaven after judgement is depicted with just angels and men. This convinces me that there are no unborn human spirits out there who never sinned or who sinned and was damned, otherwise, they would have been mentioned. In short, the entire body of scriptures argues strongly against pre-existing human spirits