I can extract values from raster by "raster to points" tool but I need to find values of surrounding eight pixels to the central pixel. And I need to do this for all pixels so I could put in a formula and create a new raster layer. However, I don't understand how to extract pixel values from the surrounding pixels in QGIS.
If you're just looking to put the result into a new raster layer, you can do that in one step using (for example) r.neighbors, from the Processing Toolbox.
Use the Neighborhood operation "average" with a weights file of:
1 1 1
1 0 1
1 1 1
That will compute the average of the 8 cells surrounding each cell and store it in a new raster:
If you want to do a different operation than the one you've described, you can use a different weights file.