What do you do when you don't know what to do?
The fact that the plan did not work could mean that the plan was bad but it could also mean that you didn't execute it well.
However, playing withought a plan is the worst thing one can do - always have an a idea of what you want to do. You can use these as guidelines:
What are the strong points of your position? of your pieces? What are the weaknesses of your opponent? how can you take advantage of them?
Don't worry if at first you don't seem to know what's the best approach, or go after something that ends up costing you. This way you learn, you get better, and next time you will possibly try something different that works. As you get more familiar with your openings and the common themes that arise later in the middle game, you will also come up with better plans.
Good luck!
for what its worth it's helped me...old time champion once said; " If u see a good move, look for a better one.
Maybe get examples in your games of this and share with stronger players for their insights. Without looking at concrete examples of positions where you felt this way, I don't think you will easily obtain your answer. Your question is of a rather broad nature so unfortunately the answers will also be the same way.
But just to throw another broad idea out there. I find that the positions where I can come up with the best plans are the ones arising from openings I have the most experience in. Usually a good opening book can help as the author describes the typical plans and motifs of the opening with annotated, illustrative games.
If there seems like nothing to do, and you can't come up with a long or short term plan, then look for your worsed placed piece (which one is contributing the least) and try and get it more involved in the game, or try and send it to an 'ideal' square.
First of all, try chaging your name to Capablanca or Lasker! 
More seriously, try reading a book on middlegames by Euwe, Fine, or Romanovsky; save Kotov's books for after you've read a few others first.
If you haven't read Nimzovitch's My System do so ASAP! Don't pay much attention to his opinions on opening theory, many of his comments on openings are way outdated.
You could also memorize Fine's 3 Basic Endgame Principles and 15 rules of endgames from Basic Chess Endings which are also applicable in most cases to openings and middlegames as well. If you decide to buy BCE try finding a copy of the original and not the algebraic update, which I read sucks ass - unless you absolutely are incapable of dealing with English Descriptive Notation.
IF you can afford to hire a personal trainer that might help a lot but being a pauper myself I would only recommend this if you can easily afford to do so.
GOOD LUCK!
In most cases, the rational plans are determined by the pawn structure, so if you learn the structures which usually arise from your openings, that will be the best guide.
Very nice answer ... studying pawn structures has a very high ROI compared to just learning 1-2 opening systems.
Improve your worst placed piece (Aagaard: christmas exercise, "what would you like for christmas, knight? where would you like to be?").
Exchange or drive away via exchange threats his best placed piece.
Try to create a weakness in his camp.
Something in between.
When in doubt, improve the positioning of your worst piece, or else aim your pieces at the opponent's king.
Whatever you do, don't sacrifice anything!
Did I say, when you see a mating attack, don't give up material for it? NO.
The OP was from someone who couldn't see what to do. A not infrequent occurence in chess. Figuring what to do when you don't know what to do is important. Improving a piece or making your own King more secure or shuffling over toward the enemy King are good bits of advice.
First of all, try chaging your name to Capablanca or Lasker!
More seriously, try reading a book on middlegames by Euwe, Fine, or Romanovsky; save Kotov's books for after you've read a few others first.
If you haven't read Nimzovitch's My System do so ASAP! Don't pay much attention to his opinions on opening theory, many of his comments on openings are way outdated.
You could also memorize Fine's 3 Basic Endgame Principles and 15 rules of endgames from Basic Chess Endings which are also applicable in most cases to openings and middlegames as well. If you decide to buy BCE try finding a copy of the original and not the algebraic update, which I read sucks ass - unless you absolutely are incapable of dealing with English Descriptive Notation.
IF you can afford to hire a personal trainer that might help a lot but being a pauper myself I would only recommend this if you can easily afford to do so.
GOOD LUCK!
Chess never changes, how can openings be outdated?
