The good old cockpit is usually one of the first areas tackled in construction, and also (usually) one of the only interior areas easily visible on an aircraft. From a modelling viewpoint it is one of the most important areas, as people looking down onto a model (as they usually do, models being displayed on tables at waist height or lower in most cases) will be able to peer inside it, and it is a point of focus on the aircraft exterior. For these reasons it is usually one of the stumbling blocks I have to finishing an aircraft model, when I think of the work ahead I often get discouraged, put everything away and go and watch TV or play computer games!
I used to paint individual items before construction, but now I have an airbrush I find it is often easier to construct, at least partially, the cockpit items before painting. Typically for WWII aircraft I put everything together except the instrument panel before spraying. In modern aircraft I generally leave out the ejection seat until after painting. With resin and etched brass update or replacement sets, I usually put the sidewall items in place, and make the rest of the cockpit tub separately to facilitate detail painting. This is only a general guide, and a certain measure of common sense must prevail. Whenever possible I try to place the cockpit in position after joining the main fuselage, or at least at the same time, as this makes centring and levelling the cockpit much easier and prevents a large gap appearing on one side, which often occurs if the item is cemented to one half of the fuselage first.
On larger aircraft or where there are areas open for viewing
(eg machine gun gays), I play it very much by ear. Generally though, in the case of areas which are very "busy", such as the machine gun bay example above, I spray the items BEFORE placing in the area. In open areas (such as the bay in a troop transport), I put everything in place before painting up.