Ore Magnet is a treasure found in Hollow Hill treasure chests. Point the Ore Magnet at the ground (or at a wall), charge it up, and release. If you are lucky, the Ore Magnet will bring anything from an ore block to a whole vein right up to the surface for you. Each ore magnet will bring 24 blocks, and perhaps a few more to the surface.
The Ore Magnet does not work on Coal Ore, but will otherwise work on any ore. It will even attempt to find ore blocks added by other mods, as long as they have "Ore" in their name. It attempts to find blocks by searching through solid rock in the direction the player is facing, with a range of 32 blocks. However, the Ore Magnet will not move any blocks that are Tile Entities: blocks that store data. It has 12 durability and uses up 1 durability for each block brought to the surface, and ores will only replace stone, dirt, grass blocks, gravel and air.