Jazz tolerates dissonance. Celebrates it, even.  However, every time you play an unexpected note in a jazz piece, you should be expected to resolve the dissonance by coming back to the key/theme of the piece.  The bigger the deviation from expectation, the more extensive this “resolved” portion needs to be.  Failing to do so makes your music nothing more than a collection of inharmonious notes.