When do you contact ATC when departing from a non-towered airport into class B controlled airspace?
I'm assuming you're VFR.

You contact ATC before you enter the Class B air space.  

If necessary, you orbit outside, but you don't enter until after you hear the magic phrase "&lt;your callsign&gt;, cleared into the Class Bravo airspace" from ATC. 

If it's a busy time and/or the weather is poor, you may NOT get that clearance.

See this blog for a more detailed explanation.

If you're flying IFR, the answer is the same except you would be in contact with ATC either before or right after take off. The Class B becomes more or less moot - they handle it for you.