I sometimes have trouble knowing when to ask a question. In the past I had been told I asked too many questions so now I make an effort to ask fewer. This basically means I try harder to find the answer by myself (usually by trying things out or reading documentation) before asking someone else. I think the problem was, when I didn't understand an explanation I didn't say anything, and when I asked again my manager got upset. So now I learned it's really important to get things right the first time around.
At another job my boss would come up to me and ask what I was doing, and I guess I phrased the reply in such away that sounded like I was stuck (though in a sense, isn't that all work is, is a series of getting stuck and unstuck?)
For example I would say "I'm trying to install the latest version of python" and he would say "what's the holdup" and I would say "I'm getting an error message" and he would say "why didn't you ask me?"
Well I could try google searching to find the solution.
This happened on several occasions so I finally asked "how long do you want me to work on something before asking you?", I think he said 10 minutes but latter at a meeting, he told his manager I asked how long I should wait until I ask him a question and said he didn't know how to reply. His manager said "as long as you think you're getting somewhere, don't ask, but as soon as you have no idea what to do next, don't waste any time and ask right away".
Admittedly, the boss was a bit of a nut case and that's why I quit. But how do you know when to ask a question as opposed to try to find the answer yourself? I would say part of it is how busy the other person is you're going to ask.