I get my best ideas in bed before sleep, in the shower or while listening to music. As for the best place to write I mostly write at home. I've been known to jot ideas and scenes down whenever they come to me though. I can't write when I'm too tired, but otherwise I try to write as soon as an idea pops up.
Usually when walking to work or indeed walking at any time is when I think up most of my ideas. It takes me twenty minutes to walk into the middle of town. During which time I think up plenty of rough ideas. So I take with me pen and paper. When I reach the coffee shop or pub I get a drink and write up the ideas now filling up my head. That said, ideas can enter your head at anytime and in any place. Which is why its a good idea to keep an A5 note book, pen and spare pen to hand. So as to note down your eureka, before it is lost forever. It is a good idea to try and find out under what circumstances you are most productive in thinking up new ideas. Obviously, that way you'll learn how to think up more ideas.