This happens to everyone. Taking a break, going for a walk, or switching to another project always helps. I have also read about an interesting technique in "Clean Coder" by Robert C. Martin. It is called the "tomato timer" or "pomodoro".
You set a timer for 25 minutes. You can use your phone, an alarm clock, Outlook, etc. In the old days people used a kitchen timer, which would often be in the shape of a tomato, hence the name of the technique. Then you work for 25 minutes without interruption. Don't check your email, don't browse the web, not even StackExchange. If you get interrupted by a phone call or a co-worker, politely ask them to call or come back after the time is up. When the alarm sounds after 25 minutes, take a 5 minute break. Every 4 "tomatos" or so, take a longer break.
Even though this is more of a way to manage distractions, rather than fight programmer's block, it should help with that too. With these regular periods of concentration you get much more done. And with the regular breaks you feel much less tired at the end of the day. I think the breaks are also a way to let your "left brain" (or is it your "right brain"?) work on the problem, which should help you when you are stuck, or even prevent you from getting stuck in the first place.