I am an amateur chess player. I have the knowledge of pawn structure, development of the pieces and control of the center in the opening. After that my midgame rationale is attacking the weak pieces, and if I am under an attack, focus on defense. This has failed to work among much stronger opponents of late. How would I change my rationale so that I can manage defense and attack at the same time?
Defense isn't something that one does; it is not a tactic. Instead, defense happens when one has ceded the initiative to the opponent. One spends moves patching holes versus attacking the opponent's weaknesses.
(Of course at some point "tactics" and "retaining the initiative" blur. Some fine attacking moves also defend, and some defensive moves free other pieces to attack. It can be a maelstrom when it comes to specifics.)
So consider reading on tempo and initiative.
It is interesting to see that you don't mention tactics in your post, while you did tag your question with it. Because, at the level you're playing, 99% of the games are decided by tactics. Practice more tactics, and you will advance quickly, especially if you know the basics of defense/offense.
You have a "Chess Planning" and "Thinking Process" problem.
Depending on your rating, I would recommend:
Reassess Your Chess - Jeremy Silman. Simple, to the point, written for <1800's.
Something with a little more substance:
Find the Right Plan with Anatoly Karpov (Batsford Chess) - Karpov, Anatoly
Me personally, I prefer Karpov's book, and tend towards his thinking process methodology. Having the weight of GM and World Champion behind is justified in the content.
As said it's all about initiative : you have it when you play with white, and the trick is to not lose it, while when you're black, you have to defend in a large part while trying to balance, steal the initiative or overturn your opponent's attacks (and some openings have been developed following this philosophy)
personally, when I lose the initiative and have to defend, I always look for a counter (a move that while defending can represent a threat, or a refutation to my opponent's attacking move by playing a stronger attacking move, example : he's threatening my bishop, I threaten his Queen)
Anyway, the better way is to never lose a tempo and let the initiative slip, but for that you have to make a well prepared attack, so that it will never let your opponent rest !
You have to study some great masters' games and see how they deploy their attacking plans which don't allow a retort.
I don't think there are any specific rules for that. One must follow the greatest games played by the masters, what they did in what situation.
I can share one of my favorite matches. Hope you'll learn something about your query. Strong combination between pieces is always a key.
You are asking what to do, if you are not sure whether to attack or defend.
First point, Never commit to an attack until you have some kind of advantage to base it on. If you dont yet have an advantage, there is no magic way to conjure one up out of nowhere.
The key to both attack and defence is mobility. Your pieces should be able to go wherever they need to. In games between top players it may seem like nothing happens for a long time, but both players are manoeuvring to make their pieces mobile. As a rule of thumb, try to ensure the each piece stands on a good square, and also has a good square to move to.
So what is a good square? It will take you a lifetime to answer that question
Hard to help you if I do not know you chess rating.
On level 1000-1600 it is really enough to seek weak points and attack - whatever if you want play better it is not enough at all - solve 2k of chess puzzles :)
On level 1600-1800 it is enough to manage tempo - whatever it is not enough to play better solve 5k puzzle and study some grand master games - try understand cooperation :)
To play 1800+ you need understand position cooperation and powers of influence and known much more about openings and endings together with middle game. It will come that you will understand much more relations between pieces and positions and see what you never seen before on the same board.
It is long way to understand chess - you learn 20% what is probably triple times more than others :)