It is very difficult to diagnose neck pain, especially going by such minimal information and without being able to physically examine your neck. For such problems, a physical examination and interview is best, as it enables the doctor to actually see the affected body part and also ask the patient questions that will help narrow down the range of possibilities. Neck pain can be an indication of very many problems. As you have guessed, one of the simpler more minor problems could be bad pillows or a bad mattress. You have not mentioned exactly how long it has been since you changed your pillows, so I wouldn't recommend ruling out a pillow problem yet. If you have spent most of the last three weeks on bad pillows, then it may take more than a week for the pain to disappear. Make sure that your new pillows are soft but firm, and not too thick. A common cause of neck and back aches are pillows that are too high; you might think you're resting, but all the while you're straining your neck muscles and joints.
A neck ache could also be due to stress - if the last three weeks are stressful, your muscles are probably tense all through the day, and perhaps even through the night. You should also consider the amount of time you have been spending at the computer or at any other activity that you may have increased over the last three or four weeks.
An injury is of course another possibility, but you haven't mentioned any, and it would not be something you would easily forget; so we can probably rule out injury as the cause. If none of these factors seem likely causes and the pain continues for another week, you should simply visit your doctor.
answered by G M