Nominally:
-
A terrorist attack is primarily intended to kill civilians or cause damage to civilian lives in order to cause fear of the attacking group, anger against the victims' own government, or otherwise cause a change of policy. The deaths of people with no relationship to any ongoing military operation or force is "a feature, not a bug". Military targets may also be hit, or the goal may even be to selectively target civilians to emphasize that their military cannot protect them.
-
A military strike is primarily intended to deteriorate an enemy force's ability to wage warfare: by killing soldiers or leadership, destroying materiel or supplies being used to fight, or destroying industry or logistics being used to support the war effort. Civilian deaths are an unavoidable side-effect of strikes primarily intended to hamper military warfighting capability.
That's the theoretical line.
In practice, of course, there are many points of disputation - how many degrees separated from a man holding a gun must a target be before it is "non-military"? If an organization which mainly targets civilians in terrorist attacks carries out an attack on a military target, that still might be referred to as a "terrorist attack", as in, "an attack by a terrorist organization". And of course, there's a degree of publicity shaping involved in this as well. But in concept, the above is your line.
Indeed, and that's why the definition hinges critically on the intended target (civilian vs. military). One could even argue that if you, as a civilian, see your nation's military forces march out and get torn to ribbons, and then the next night your city's sky is alive with enemy aircraft bombing military, government, or materiel targets, you have pretty good reason to be scared. But we wouldn't call this terrorism, even if there are some civilian casualties, because the primary targets are all legitimate ones intended to hamper your ability to wage war.
This is another good point. We nominally expect that organized nations will adhere to the laws and customs of war. More critically, non-state actors also tend to not have uniforms, stash materiel among civilian populations (often even on sites protected under said laws and customs), and deliberately introduce ambiguity as to whether a target is military or civilian.
But this logic can also get murky when we consider states not recognizing other governments or arguing they are "occupied" by another, more ephemeral hostile force. It can be advantageous for a state to portray their enemy as an ephemeral, non-state actor, in part because it lets you portray the enemy as not adhering to laws and customs of war.