I used to have this problem when I first started playing Call of Duty. I'd get shot out of nowhere (seemingly). It just takes practice. Minimap, audio, know your maps. Watch your back, stick with your squad, take corners with a scope and, if in doubt, throw a nade.