I know what's the difference between the two, however I am a little confused on to use them. I have also seen some models that have a mix of both. what's the logic behind it? or is it only random things?
As known, the main difference between the Convolutional layer and Dense layer is that Convolutional Layer uses fewer parameters by forcing input values to share the parameters. The Dense Layer uses a linear operation meaning every output is formed by the function based on every input. In other words, we "force" every input to the function and let the NN learn their relation to the output. As a result, there appear n*m connections (or weights) where n denotes the number of inputs and m denotes the number of outputs. On the other hand, the Convolutional layer uses a filter to operate the convolution operation which has a small size most of the time. An output of the convolution layers is formed by just a small size of inputs which depends on the filter's size and the weights are shared for all the pixels. That is, the output is constructed by using the same coefficients for all pixels by using the neighboring pixels as an input.
In the convolutional layer, as known, the filter's center is located in the pixel and then the linear operation is processed using the neighboring pixels of that pixel. That is, we, in advance, know that there is a strong relationship between the neighboring pixels. If we would not be sure that the neighboring pixels have a strong relationship with neighboring pixels it would not be logical to use Convolutional Layer, instead we would force all the pixels (inputs) to the function to learn the relationship by using Dense Layer. So, by using Convolutional Layer we assume that the neighboring pixels are the main representative of the center pixel and as we go far away from the pixel, that is the pixels that are away from the center pixel do not really possess the same characteristics as the center pixel. They might even be a different object thus may lead to a spurious result or would cause your function to learn redundant information which in reality has no relationship with.
In short, since we have prior knowledge about our data and information in it, we not only take the heavy load from our model by using a convolutional layer but also show it the exact location of the data that might be useful for it to learn while keeping it away from redundant data. However, frequently we use both in the same model, it is often simply due to we do not what is going on in layer 10 (for example). Namely, we do not have that prior information about data anymore, because we do not know what it learns in those deep layers. Thus, we use Dense Layer, by giving all the inputs, we give the "full responsibility" to learn. In other words, we say to a Dense Layer that "Here are my features (pixels maybe), I don't know the true relationship between them, please find it yourself". We say to a Convolutional Layer that "Here are my features (pixels maybe), I am sure that it is enough just to look the few pixels around the center pixel" and that relationship is preserved through all the pixels.
So knowing, how it works, in different contexts, you can apply them to different scenarios. If you have a good knowledge of your data and its structure then you can choose the relevant layer while designing your model.