When I first started playing competitive chess 50 years ago what you describe was standard practice in blitz but not allowed in standard time control chess. Nowadays it is not allowed at all except in the case that moving the piece was not legal, for instance because it left your king in check or placed your king in check.
According to the current FIDE Laws of Chess:
4.7 When, as a legal move or part of a legal move, a piece has been released on a square, it cannot be moved to another square on this move.
Legal and illegal moves are defined so:
3.10.1 A move is legal when all the relevant requirements of Articles 3.1 – 3.9 have been fulfilled.
3.10.2 A move is illegal when it fails to meet the relevant requirements of Articles 3.1 – 3.9
There are two cases when the requirement for the move to be legal would allow you to take the move back, indeed require you to do so.
The first is if your king ended up being in check after your move:
3.9.2 No piece can be moved that will either expose the king of the same colour to check or leave that king in check.
The second is if you move a piece in a way it is not allowed to. You can take the move back if, in your example, you moved your queen to a square it is not allowed to move to, for instance you moved the queen like a knight:
3.4 The queen may move to any square along the file, the rank or a diagonal on which it stands.