What determines whether an action potential is inhibitory or excitatory?
Short answer
The physiological state of the postsynaptic cell ultimately determines the effect of an incoming action potential.

Background
An action potential occurring in a chemical synapse is neither inhibitory or excitatory. An action potential is a binary '1', an-all-or-nothing signal without any information, i.e., there is not a -1 or +1 action potential. Similarly, there are no excitatory or inhibitory neurotransmitters. 

Notably, the principal excitatory neurotransmitter in the nervous system, glutamate, can have inhibitory effects dependent on the receptor activated. While most metabotropic glutamate receptors (mGluRs) and ionotropic AMPA and NMDA receptors are indeed all excitatory, the inhibitory glutamate receptors (iGluRs) are not (Cleland, 1996). 

Conversely, GABA, the principal inhibitory neurotransmitter in the nervous system, can have excitatory postsynaptic effects. For example, hyperpolarized neurons may actually depolarize upon GABAA receptor activation, simply because the resting membrane potential is more negative than the reversal potential of Cl- (i.e., Cl- flows out of the cell due to the negative membrane potential) (Marty &amp; Liano, 2005).  

The existence of both excitatory and inhibitory glutamate receptors shows that it is the postsynaptic receptor that determines whether an action potential will inhibit or excite the postsynaptic neuron. The excitatory effect of GABAA activation shows that on top of that, even principal inhibitory neurotransmitters (GABA) with principal inhibitory receptors (GABAA) can excite a neuron dependent on its physiological state.    

Besides chemical synapses there are electrical synapses. In these synapses action potentials are transmitted directly electrically through gap junctions. In this case, any action potential is excitatory as the signal will be carried forward if it is strong enough (Purves et al., 2001).  

References
- Cleland, Mol Neurobiol (1996); 13(2): 97-136
- Marty &amp; Liano, Trends Neurosci (2005); 28(6): 284-9
- Purves et al., Neuroscience, 2nd ed. Sunderland (MA): Sinauer Associates; 2001.