First forget about QGIS when playing with 3D, QGIS is not really there yet. If extracting vertices is enough or the lines are isolines (contours - constant elevation) then it is possible to use approach with free tools as explained here:
Importing 3D DXF file into QGIS with z information as attribute value?
The problem is when the lines in DXF have actually vertices in different elevations. In that case GRASS skip these lines when running v.to.rast. I think the only way in that case is to densify vertices on these particular lines to some needed minimum distance and extract them as points - v.to.points (dmax = your wanted minimum resolution value).
So in this case the process in open source GRASS (comes together with QGIS OSGeo4W installation):
v.in.dxf - to import contours including z dimension
v.to.points (dmax=) - to have all as points - while making sure lines become enough (dmax) dense points
v.to.rast (use=z) - convert dense points to raster
r.surf.contour - to linearly interpolate the rest of the surface (DEM) between points (lines)
In this case it is also possible to use other r.surf.* or interpolate from points v.surf.* or use v.out.ascii to export points to ascii x|y|z format and use any other software for surface interpolation