To my knowledge (and on the base of some of the last castle attacks I have seen)- yes, city guards defend the castles too. But I don't think they can participate in an outpost battle (doesn't seem logical to me, since the guild which owns the castle can't build outposts in its province).