When I'm filming video with my Canon EF-S 10-18mm f/4.5-5.6 IS STM lens, strange dark spots appear in the video and they are only visible in video mode and they are visible ONLY when focusing process is finished. In the picture below you can see on the upper side clean image, because its still focusing and the bottom with all these spots.... Here is a sample video with the problem https://youtu.be/EvPOdjagw3k Any ideas what is causing it and how to fix it ?
This appears to be sensor dust. The simplest way of cleaning it is using a blower, however there's a much more comprehensive article on this on bythom.com (don't be worried by the frequent Nikon references or the slightly out of date content - it's all still solid advice).
Hard to be certain about why you're seeing it in video mode mostly, but at a rough guess I'd say it's because in video mode your camera will tend to shoot frames with a shutter speed thats about twice the frame rate, which may be forcing it to use a narrow aperture (a high f-number) to get the right exposure. Dust is generally only visible at high f-numbers (narrow apertures).
For stills, while the camera is out of focus it has aperture open as wide as possible (that's how DSLRs work) and it will stop down when it has locked focus and takes the shot. That's why the dust spots are sharp and small in the focused shot (stopped down to a narrow aperture) and faint and diffuse in the unfocused shot (camera still at a wide aperture).
Now I'm a little surprised to see that behavior in video mode on a DSLR but that appears to be what is happening. I'm not a video expert, however, and this isn't a video forum so my expectation is not a reliable guide to video.
Note that sensor dust is practically invisible to the naked eye.
If you had dust causing such a problem on the lens it would be larger pieces - you might even see those with the naked eye. You can try using a lens pen to gently clean the rear element of the lens just to be sure you're covering all the bases, but I'd expect lens dust to be much less obvious.