All obedience should ultimately be rendered unto God if it is to be a virtue under Justice. If it is not rendered unto God, then it is neither a virtue, nor just, but merely servile or mechanical.
The authority to command, i.e. make others obey, with which men are endowed is exercised when it itself is obedient. Otherwise the link is broken in the chain of obedience that ultimately leads to God, and the one who commands is no longer vested with authority.
Authority to command is properly exercised when the one who commands expresses the will of God. The will of God may be expressed more or less generally, for all at all times, such as the command to love God above all things, and to love one's neighbor as one's self, or to particular groups or persons, or at particular times or circuмstances. Thus when Our Lord commanded His Apostles to teach the nations, baptizing them in the name of the Father, Son and Holy Ghost and to teach them to observe His Commandments, or when He told the servants at the Wedding at Cana to fill the clay jars with water.
All authentic expressions of the will of God concur. Thus it is God's commandments that Christ gave to His Apostles, and they to their successors, expressed in Councils and Catechisms, sermons and laws, laws and customs, by generations of bishops and kings and parents.
Because man's nature has been corrupted by sin, however, by the disobedience of our first parents prompted by the disobedient angel, at times conflicts of expression occur. A father may command his children to lie or cheat or steal. A king may command his nation and its bishops to recognize him as head of the Church. Laws may be passed the forbid Christianity, or protect and promote sin and vice. A priest or bishop may lead his flock into schism, or heresy, or sacrilege.
Or the conflict may be in the mind of the subject. Do I provide insurance for my employees that pays for abortion or contraception? Do I attend my relative's or friend's non-Catholic wedding? Do I go to work on Sunday or the Feast of the Assumption?
When there is a conflict, one must try to discern the will of God. Often the will of God can be discerned from a more reliable source: the Church over the state, faithful practicing parents over secular teachers, the unchanging, immemorial, universal belief and practice of bishops and doctors of the Church and innumerable saints over inconsistent, recent or particular innovations, one's confessor over the internet.
Note that the discernment must be of the will of God, and the source must be reliable. Conflict or confusion should not be a convenient occasion to justify doing one's own will. Unjust commands do not justify vigilantes. Likewise, one's own opinions are not a reliable source for discerning the will of God.
Lastly, obedience is a virtue, and like all virtues it is a habit, and habits, whether virtuous or vicious, are developed by repetition over time. One who is habitually disobedient may on occasion be obedient, but will be consistently inclined toward disobedience, especially in grave or important matters. Conversely, one who is habitually obedient may occasionally disobey, but will consistently be inclined to obey, especially in grave and important matters. The habitually disobedient do not worry about obedience, but those have fostered the virtue of obedience sometimes suffer great pangs of conscience, or with longanimity are willing to bear mistreatment by men, for the sake of obedience to the will of God.
No better example of obedience than Christ, Who was accused by the legitimate religious authorities of His day of breaking the Sabbath and of blasphemy, and by the political authorities of ѕєdιтισn, Who was criticized and abandoned by His own followers, Who sweat blood in submitting to God's will, and Who shed the very last drop of His Precious Blood in fulfilling it.