It's probably helpful to ask oneself why a move such as f3/f6 (moving forward, I will only consider f3, but it should work from black's perspective as well) would be useful in general. Why would I ever even consider making such a move? The very obvious reasons should be clear to most: if I want to reinforce/control/attack the squares e4 and/or g4, then of course the pawn move to f3 could be very useful. Another very obvious reason for making the move is of course the pawn being attacked.
For reasons a bit more subtle, the move could also prove useful if I for some reason wish to vacate the f2 square (for instance, to clear the h4-e1 diagonal for my dark-squared bishop if it were pushed back by a black pawn mass). Another subtle reason is that the move could be used in a pawn endgame in favour of the immediate f4 push for tempo-related reasons, or more generally to induce zugzwang.
I've now listed all good reasons for making the move that I've been able come up with. If you can think of another general scenario where specifically f3 is called for, feel free to suggest it; I'm having a difficult time coming up with any other good general reason to play the move.
Now for the fun part: Why would I not wish to play f3? This question is equally important to the first one if you want a good heuristic for when to play f3. The reasons for not playing the move that I can think of are the following:
- It blocks the f3 square for the g1 knight. This is a major drawback of opening systems that make an early f3 push in the opening, see for instance the Sämisch system against the KID.
- It begins opening up the a7-g1 diagonal. This is generally not great since white's king is often on g1, just waiting to be harrassed if this diagonal opens.
- It weakens the control over the e3 square. This means that White's dark-squared bishop doesn't really have a safe haven on e3 anymore. This is a common way to lose as White in, say, the open Sicilian.
- It blocks the d1-h5 diagonal for White's queen/light-squared bishop.
- It creates a so-called "hook" for Black's pawns/pieces to attack in a potential kingside attack by Black.
- It can be a waste of time if I'm in a pawn race (either literal pawn race in an endgame or a "pawn storm" race). Sometimes you can go ahead with the pawn push g2-g4 without even defending the square first; after all, if I'm aiming to use a pawn storm to soften up black's king on the kingside, removing the g pawn opens up the g-file for my rook. This last point is highlighted in many games in the open Sicilian, where White attacks Black's king on g8 while Black attacks White's king on b1; in these races, every tempo counts.
Again, if you can think of another good reason not to play f2-f3, then feel free to add it to the list. Know these reasons well, because some of them are not that immediately obvious why they are a big deal. For instance, giving up control over the e3 square may seem innocent enough, but in many cases it can be surprisingly detrimental to your position, especially if the position is not closed. Therefore you shouldn't make weakening moves such as f3 without a clear intention in mind.
While I haven't really heard the rule-of-thumb to "never play f3/f6", the above list of reasons not to play it seems like a good explanation as to why someone gave you that advice; most of the points I listed above are not easy for a beginner to fully appreciate, so it's simpler to just remember "don't play f3/f6" when you're still new to the game. After all, before you can break the rules, you have to understand them first.
Therefore, as you're now no longer a beginner (as indicated by your rating), I would propose this new and improved heuristic for the f3/f6 move:
Never play f3/f6 if the good reasons for playing it do not outweigh the negative side-effects of playing it.
As you can see, this advice would be pointless to give to a beginner, but for a player who is starting to learn things beyond the bare basics of positional chess it is much more suitable - after all, as you get stronger you will notice that every decision you make is a tradeoff between pros and cons of that decision. Even the obvious moves are decisions which are made easy by the fact that it's very clear what part of the pro/con list outweighs the other, but more difficult positional decisions may sometimes seem like a coin toss. In general, your chess ability is directly tied to how well you manage to accurately make up the list of pros and cons for given moves, and in the more difficult cases you will not be able to use the crutches that are commonly given to novice players to evaluate a decision with accuracy.