I’ve noticed occasionally whenever I start to put down a glass of water quickly it splashed up, even without it making contact with the desk. And another example is when I have the faucet running after I brush my teeth, if the sink fills up a bit and I spit the toothpaste into it water splashes up with the toothpaste. Why does this happen?
Firstly, there is a relevant physics stackexchange answer here: Why is the splash of water always vertical, no matter in which angle the gunfire hits the surface? That was for a gun firing onto the water surface.
You mentioned two cases: Placing a glass of water and spitting into a body of water.
In the case of placing a glass of water on a desk, decelerating the glass rapidly before placing it on the desk, you cause disturbances on the water surface which result in waves. Sooner or later, the right combination of waves cause the water to break free from the surface and cause a splash as seen in this video.
As for spitting on the water surface, the initial impact of the spit droplets causes a reaction that pushes water back upwards after the droplet has landed. The temporary void or hole cause by the landing of the droplet results in a circular wavefront rushing inwards to fill the void. As the wavefront meets, water is pushed upwards, sometimes causing a spectacular splash, as seen in this video.
Your first example: This will only happen if you move the glass faster than the contained water can follow due to gravitation. You basically "pull the glass away" from the water which creates turbulences inside it. If you do it violently with a lot of force, the water will already splash at this point. Once you slow down, the water will "fall" back into your glass where its momentum is reflected from the glass' bottom causing the water to splash again. Since water is liquid, its momentum is not reflected like it would be for a rigid body but the glass prevents it from splashing sideways so the only direction is upwards.
Your second example is in a way similar. You spit something in the sink with a given momentum. If the momentum is small (just as putting a glass down slowly) nothing will splash because the water can reorder around the object. If the momentum is large on the other hand, you will cause turbulences that make the water splash. If you manage to spit so forcefully that you hit the bottom of the sink, the toothpaste will be deformed (kinetic energy will be used for the deformation) but part of it will also be reflected and splash up taking some water with it.