Shortly after my fiance and I get married I will deploy to Iraq for the first time. I, being an infantry soldier, am trained to kill. It has always been a major concern of mine to kill in war, and I wonder if this is a sin recognized by God. I figured since and before the biblical times, there has always been war. God was with David when he killed Goliath. I'm not much on Bible smarts, but I know there were many other occasions God was with someone, or other peoples when killing. So my question is, is it ok to kill others while at war? Thank you for your time, sir.
You seem to be making a habit of committing yourself to a course of action and only afterward wondering if you made the right decision. The appropriate thing is to know in advance that your chosen course of action is correct because you did your homework, then you can move forward with confidence. Though talking about food, the principle remains the same: "Do you have faith? Have it to yourself before God. Happy is he who doesn't judge himself in that which he approves. But he who doubts is condemned if he eats, because it isn't of faith; and whatever is not of faith is sin" (Romans 14:22-23).
In regards to your question, I addressed a broader question earlier that also touches on your question: "May a Christian serve in government?" The questioner was particularly concerned about the functions of a government that might involve killing, such as a police officer or a soldier. Rather than repeat it here, I will ask that you read it. I was also asked, "Should a Christian serve in the military?" I happen to have a neighbor and fellow Christian who serves in the Air Force, who kindly offered to address the question directly. To understand all that is being presented, you will need to read all the verses he cited and not just the article, but it is well worth the study time.
Finally, you raised a good point in noting that God obviously made use of killing in the past. Again there is a prior question, "How can God command us not to murder when God murdered people in the Old Testament?" which addresses this issue. By reading the verses involved you will be able to stand on your moral decision because of facts and not just your personal opinion.
To everything there is a season, a time for every purpose under heaven:
A time to be born, and a time to die;
A time to plant, and a time to pluck what is planted;
A time to kill, and a time to heal;
A time to break down, and a time to build up;
A time to weep, and a time to laugh;
A time to mourn, and a time to dance;
A time to cast away stones, and a time to gather stones;
A time to embrace, and a time to refrain from embracing;
A time to gain, and a time to lose;
A time to keep, and a time to throw away;
A time to tear, and a time to sew;
A time to keep silence, and a time to speak;
A time to love, and a time to hate;
A time of war, and a time of peace.