Who determines what a valid law is?
The person with authority to do so.
If the LG king is overthrown and the a CE one legally takes up the scepter that signifies rulership, do all the L characters in the kingdom have to just submit and do whatever the new king says?
The lawful neutral ones certainly do, if the ruler legally took up the scepter. They may personally despise him, but without a legal recourse for disposing him, it is the essential nature of LN to say that greater wrong would be perpetrated by usurping a lawful ruler than anything else that is possible. Of course, actual Lawful leaning nations have all sorts of traditions and rules that exist at a higher level than any mortal ruler which the ruler is expected to be subject to, and in your particular example its highly unlikely that existing law recognizes right of conquest or any other sort of usurpation. The legal ruler would not be the one that overthrew the LG king, but rather the LG kings legitimate heir. Now concievably, the LG ruler could be overthrown by an enemy, and the legitimate heir could be CE, and indeed in that case the LN characters are required by their honor to swear fealty to him.
LG characters on the other hand live in a tension. They must be both lawful and good and those things can be in tension. The situation you suggest would likely cause a schism amongst the LG knights - some of whom would take the more lawful part and some of whom would argue that the right to rule is predicated on the fact that the ruler's rule is just and good and is forfieted when this isn't true. Depending on the foresight of the previous rulers, this could be specified explicitly by tradition. For example, it might be in the power of the High Priest to declare the current ruler and apostate, relieving all the lawfuls of their obligation and oaths to the King. And so forth. But in a LE tending autocracy, obviously your LG inclinations are greatly in tension with the law... which sounds like a great basis of play as far as I'm concerned.
If you're visiting another country, which laws do you follow?
Your code will tell you. Generally lawful codes present a heirarchy of duties so that if your obligations are in conflict, you know which duty you have to fulfill. Generally speaking, your duty to your leige out weights duty to a local ruler if those two are in conflict. If the code doesn't tell you, you're up a creek without a paddle and you'll probably have to fish around for something else in the code that tells you how to behave.
If the king starts to go insane with Wormtongue whispering in his ear, all of the followers get drug along?
The lawful neutral ones do, although they may have great personal misgivings about it. After all, he is the King and can't be gainsayed. If their misgivings are grave enough, they may start looking for legal loopholes and the like, so that they can obey the letter of the king's commands but not the spirit on the grounds that the king's commands themselves are contrary to the spirit if the law. It's worth noting that this situation is exactly the one that prevailed in Theoden's court.
Can an areligious kings never be lawful since there is no highest authority beyond themselves to write the laws?
The highest authority need not be a diety, though in D&D it usually is. The highest authority could be a mortal law giver or simply a body of inherited written law. A good example of this IMO is from the biblical story of Daniel in the Lion's Den, where the King passes a proclamation, immediately regrets it, but finds himself unable to undo his proclamation because his courtiers (rightly) point out that by the law he is unable to do so - and the King just goes along with this because he knows that they are right (and he'll lose his lawful authority if he breaks the law).
What if you're raised in the wilderness that has no king or whatnot?
This is probably one of the reasons that D&D associated (wrongly) barbarism with chaos. However, if you are raised in the wilderness and lawful, then you are probably placing yourself subject to clan or tribal law, or even a Kiplng style 'law of the jungle'. Whatever is claiming an external reviewable code that must be followed, is the lawful influence in the environment. A lawful character raised in the absence of such a code would be really interesting, because he would feel completely rootless and without a place in the world, but I would guess would simply gravitate toward the first code that was revealed to him that fit his moral needs. Prior to that time he'd just feel that the world was somehow wrong.
Two LG generals at a border find in a border dispute that each country's respective laws demand that the other immediately be driven out... let the slaughter commence?
Yes. Indeed. Although, each of course would probably respect the other as a noble foe, and would seek to extend to the other all the curtsey and mercy that their honor and situation would allow.