it is not easy to write a formula based on the narrative you supplied (a sample sheet with all the options would go a long way to help) but...
something like =IF(OR(G2=3,G2=4),"",if(J1=???,(J4+E8-F8),IF(K1=???,(K4+E8-F8),"")))
but you are leaving out a lot of information. What to do with the other two selections from G for example, where does the J account option appear? same for the K account option?
maybe you can adjust things based on what I've written.