Origin unknown, but this phrase was recently popularised by Dale Howard from Big Brother 9 in the UK.
It describes someone who makes themselves look stupid when they say certain things. Hence they look stupid(as you would if you talked with your dick hanging out).
Can also often mean that someone has double standards and possibly quite hypocritical behaviour
"Rex is probably taking notes on me anyway, talking with his fucking dick out all the time. I'll be doing something and he'll be doing the same thing all the time so he can't say anything. He's just talking with his dick out *cue Jennifer pointing to Rex across the garden who Dale hasn't spotted yet*