A good rule is that if you can't force your way into a better position from the sacrifice then don't do it. In that context a better position is based upon your own evaluation. That can only come with experience and learning. In the first approximation, it's just counting up points of the pieces on the board. Beyond that you'll rarely want to go more than one pawn down. If you choose to do that then the compensation you're looking for needs to come in the form of initiative. That can come from attacking opportunities on the opposing King or Queen or generating options when you previously were facing only pressure from your opponent's attacks. There are undoubtedly more advanced methodologies for statically evaluating a position but I don't know them. Think along the lines of some pieces are more valuable on some squares; counting attacks and defences on squares; squares controlled; some squares are more valuable than others; etc.
When should I sacrifice?

the soundness of your sacrifice can be evaluated depending how weak your opponent position and pieces is
are they far? or are they close enough to defend? do you have enough attacker for a follow up the attack? etc.
thanks for the advice

A good rule is that if you can't force your way into a better position from the sacrifice then don't do it. In that context a better position is based upon your own evaluation. That can only come with experience and learning. In the first approximation, it's just counting up points of the pieces on the board. Beyond that you'll rarely want to go more than one pawn down. If you choose to do that then the compensation you're looking for needs to come in the form of initiative. That can come from attacking opportunities on the opposing King or Queen or generating options when you previously were facing only pressure from your opponent's attacks. There are undoubtedly more advanced methodologies for statically evaluating a position but I don't know them. Think along the lines of some pieces are more valuable on some squares; counting attacks and defences on squares; squares controlled; some squares are more valuable than others; etc.
I think of that too, sometimes I sac one or even two pawns for a lead in development
the soundness of your sacrifice can be evaluated depending how weak your opponent position and pieces is
are they far? or are they close enough to defend? do you have enough attacker for a follow up the attack? etc.