There are a few different issues in the air with your question.
Whether it's morally permissible to break the law depends on whether, or under what conditions, there is a moral obligation to obey the law in the first place. This is an old philosophical question, perhaps addressed most memorably by Socrates in the Crito, where he argues that it would be wrong for him to escape from Athens to avoid his death sentence. The question of whether (and how) we have a moral obligation to obey the law has come to be known as the question of "political obligation." (http://plato.stanford.edu/entries/political-obligation/). Philosophers disagree about whether such an obligation exists. 'Philosophical anarchists' maintain that there is no obligation to obey the law as such (though there may be an obligation to obey laws that require us to do what we are morally obligated to do anyway). Those defending political obligation offer a variety of different arguments, appealing to the notion of a 'social contract,' a duty to rescue, duties of gratitude, etc. The general strategy there is to try to show that political obligation is a species of some other obligation we should recognize.
Supposing there is an obligation to obey the law, how far does it extend? Are we ever permitted to disobey unjust laws, as you propose? Note that its being permissible to obey the law and its being a duty to break the law are different -- and in general, we should be more skeptical about the latter than the former. There are plenty of laws that may well be unjust but it would be surprising if we have a duty to break them. There are tax laws I think are unjust, but I'm confident I don't have a duty to break them. Drug laws often impose unjust penalties, but I certainly don't think I'm obligated to wander around in public displaying my illegal narcotics so that I can be arrested and subject to the unjust drug laws. So the central question here is whether it's ever morally permissible to break the law -- the situations where it's a duty to break the law are a subset of these, and likely rare.
Finally, you ask about acting as a public official vs. acting as a private citizen. The position you advocate has an estimable history. Kant, for example, in his essay "What is enlightenment?" (http://www.columbia.edu/acis/ets/CCREAD/etscc/kant.html) , argued that there are 'private' and 'public' uses of reason. One and the same individual who, say, advocates against a law in his private life (attending rallies calling for its repeal, for instance) is nevertheless obligated to enforce and uphold that law in her capacity as a public official.